正文
增加 138 行删除 7 行
123456789101112131415161718193 行未改动23242526272829303171 行未改动103104105106107108:::info[通用]```cpp#include<bits/stdc++.h>#define int long longusing namespace std;inline int read(){int x=0;bool f=0;char ch=getchar();while (ch<'0'||ch>'9'){if(ch=='-') f=1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}return f?-x:x;}inline void write(int x){if(x<0){x*=-1,putchar('-');}if(x>9){write(x/10);}putchar(x%10+'0');}signed main(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int n;cin>>n;}```::::::info[优先队列]```cpppriority_queue<int>qwq;//大根堆3 行未改动int a;bool operator < (const yzc& b)const{return a<b.a;}};priority_queue<yzc>qu;//大根堆吧```::::::info[最小费用最大流]71 行未改动return 0;}```::::::info[提示]12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182833 行未改动8788899091929394959697989910010110210310471 行未改动176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239# 工具-》编译选项-》(建议选择debug)## 编译时加入以下命令:-O2 -Wall -Wextra -Wpedantic1. -O2:标准优化级别含义:启用 GCC 推荐的“生产环境”优化级别。2. -Wall:启用常用警告含义:启用一组广泛认为有用的编译警告信息(注意:它并不表示“所有”警告)。3. -Wextra:启用额外警告含义:开启 -Wall 未覆盖的额外警告信息。4. -Wpedantic:严格遵循语言标准含义:强制编译器严格遵循 ISO C/C++ 标准,拒绝任何编译器特定的扩展用法。## 在连接器命令行加入以下命令:-static-libgcc -std=c++14 -Wl,-stack=12345678901. -std=c++14含义:指定编译器使用 C++14 标准进行代码编译。2. -static-libgcc含义:强制静态链接 GCC 的底层运行时库(libgcc)。3. -Wl,-stack=1234567890 的作用是将程序运行时的栈空间大小设置为指定字节数。:::info[通用]```cpp#include<bits/stdc++.h>#include<bits/extc++.h>#define int long long#define max(a,b)(a>b?a:b)#define min(a,b)(a<b?a:b)using namespace std;using namespace __gnu_cxx;const int N=1e6+5;int t,n,a[N];rope <int> a;//平衡树,兑//inline int read(){int x=0;bool f=0;char ch=getchar();while (ch<'0'||ch>'9'){if(ch=='-') f=1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}return f?-x:x;}//inline void write(int x){if(x<0){x*=-1,putchar('-');}if(x>9){write(x/10);}putchar(x%10+'0');}//mt19937 qwq(/*一个整数作为种子*/114514);//定义完之后调用 qwq() 就可以获得一个随机数 qwq。signed main(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);//如果用手写快读记得把这三行注释了谢谢喵//多测cin>>t;while(t--){cin>>n;}//单测cin>>n;}```## solution使用 pb\_ds 库中的 rope 解决。### 介绍一下 roperope 是 pb\_ds 库中的一个分支,内部是一个块状链表,支持可持久化。需要 `#include <bits/extc++.h>` 和 `using namespace __gnu_cxx;`。### rope 的使用可以直接使用 `rope <int> a` 来声明一个叫做 `a` 的 rope 。`a.append(x)` 可以在 rope 后面添加一个元素 $x$,类似于 vector 。`a[x]` 可以询问 rope 中下标为 $x$ 的元素,默认下标从 $0$ 开始。`a.insert(x, y)` 可以在下标为 $x$ 的位置前插入元素 $y$。::::::info[优先队列]```cpppriority_queue<int>qwq;//大根堆3 行未改动int a;bool operator < (const yzc& b)const{return a<b.a;}/*或friend bool operator < (yzc a,yzc b)const{return a.a<b.a;}*/};/*或bool operator <(const yzc& q,const yzc& p){return a.a<b.a;}*/priority_queue<yzc>qu;//大根堆吧```::::::info[最小费用最大流]71 行未改动return 0;}```::::::info[分块]抓一篇题解。# 题解:P13981 数列分块入门 6## solution使用 pb\_ds 库中的 rope 解决。### 介绍一下 roperope 是 pb\_ds 库中的一个分支,内部是一个块状链表,支持可持久化。需要 `#include <bits/extc++.h>` 和 `using namespace __gnu_cxx;`。### rope 的使用可以直接使用 `rope <int> a` 来声明一个叫做 `a` 的 rope 。`a.append(x)` 可以在 rope 后面添加一个元素 $x$,类似于 vector 。`a[x]` 可以询问 rope 中下标为 $x$ 的元素,默认下标从 $0$ 开始。`a.insert(x, y)` 可以在下标为 $x$ 的位置前插入元素 $y$。## code```cpp#include <bits/stdc++.h>#include <bits/extc++.h>using namespace std;using namespace __gnu_cxx;int n, op, l, r, c;rope <int> a;int main() {ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);a.append(0);cin >> n;for (int i = 1; i <= n; i++) {cin >> c;a.append(c);}for (int i = 1; i <= n; i++) {cin >> op;if (op) {cin >> c;cout << a[c] << '\n';} else {cin >> l >> r;a.insert(l, r);}}return 0;}```::::::info[提示]:::