-
个人简介
#include<bits/stdc++.h> #define ll long long using namespace std; const int t=1e5+5; ll n,m,a[t]; int main(){ std::ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); return 0; }
快速排序
1.介绍 快速排序(Quick Sort)是从冒泡排序算法演变而来的,实际上是在冒泡排序基础上的递归分治法。快速排序在每一轮挑选一个基准元素,并让其他比它大的元素移动到数列一边,比它小的元素移动到数列的另一边,从而把数列拆解成了两个部分。
void f(int l,int r){ if(l>=r) return ; int i=l,j=r,key=l; swap(a[key],a[r]); while(i<j){ while(a[j]>=a[key] and i<j) j--; while(a[i]<=a[key] and i<j) i++; if(i<j) swap(a[i],a[j]); } swap(a[j],a[key]); f(l,j-1); f(j+1,r); }
#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; size_t pos = 0; while ((pos = s.find("ABC", pos)) != string::npos) { s.erase(pos, 3); // 回退两位以检查删除后是否形成新的"ABC" if (pos > 1) pos -= 2; else pos = 0; } cout << s << endl; return 0; }
-
通过的题目
- P190
- P192
- P198
- P202
- P203
- P230
- P234
- P261
- P262
- P263
- P282
- P295
- P298
- P300
- P303
- P305
- P330
- P337
- P338
- P339
- P343
- P344
- P347
- P348
- P349
- P351
- P352
- P360
- P362
- P375
- P391
- P401
- P402
- P403
- P405
- P406
- P407
- P409
- P410
- P412
- P416
- P420
- P425
- P430
- P436
- P447
- P449
- P450
- P451
- P452
- P454
- P456
- P508
- P596
- P603
- P656
- P684
- P692
- P694
- P697
- P708
- P722
- P723
- P733
- P747
- P754
- P755
- P756
- P757
- P771
- P772
- P773
- P778
- P788
- P789
- P790
- P791
- P792
- P799
- P800
- P801
- P802
- P804
- P806
- P816
- P824
- P934
- P951
- P969
- P976
- P1093
- P1094
- P1101
- P1912
- P1916
- P2012
- Z15
- Z17
- P2112
- P2113
- P2358
- P2411
- P2412
- P2414
- P2534
- P2565
- P2574
- P2596
- P2606
- P2608
- P2668
- P2669
- P2670
- P2671
- P2734
- P2755
- P2756
- P2779
- P2781
- P2811
-
最近活动
题目标签
- 初窥门径
- 108
- 顺序结构
- 50
- 分支结构
- 41
- 驾轻就熟
- 41
- 略有小成
- 35
- 循环结构
- 35
- 循环嵌套
- 20
- 递归
- 18
- 电子学会三级
- 15
- 一维数组
- 14
- 其他
- 13
- 递推
- 13
- 搜索
- 11
- 融会贯通
- 11
- 排序
- 10
- 枚举
- 10
- 贪心
- 9
- GESP二级
- 9
- 字符串
- 7
- 二分查找
- 6