正文
增加 39 行删除 6 行
123425 行未改动3031323334353637387 行未改动4647484950515253544 行未改动596061626364656642 行未改动109110111112113114115116117118### 对拍::::info[扩展名改成 `.bat`]```cpp25 行未改动while(c<'0' or c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0' and c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}return x*f;}```::::7 行未改动}```::::### 快速幂 [P1226 【模板】快速幂](https://www.luogu.com.cn/problem/P1226)### 离散化::::info[代码]4 行未改动if(b[i]!=b[i-1])c[b[i]]=++ii;/*c[i]表示的是值为i的数离散化后的数*/for(int i=1;i<=n;i++) b[i]=c[a[i]];/*b[i]是离散化后的数组*/```::::### tarjan(连通性) [P2863 [USACO06JAN] The Cow Prom S](https://www.luogu.com.cn/problem/P2863)[博客园](https://www.cnblogs.com/yanyiming10243247/p/9294160.html)42 行未改动### 2-SAT [P4782 【模板】2-SAT](https://www.luogu.com.cn/problem/P4782)::::info[记住就行]一般我们求解 2-sat 的过程为:1. 建图(具体略)2. 对图求出强联通分量,并求出缩点后的拓扑序3. 若存在对应同一个变量的两个结点在同一个分量内,即无解4. 否则一定有解;对每个变量取所在分量拓扑序较大的那个对应结点,一定能构造出一组合法解::::1234567891025 行未改动36373839404142437 行未改动5152535455565758596061626364656667686970717273747576777879804 行未改动85868788899091929394959697989942 行未改动142143144145146147148149150151### 保留位数```cppprintf("%.3f",a);cout<<fixed<<setprecision(3)<<a;```### 对拍::::info[扩展名改成 `.bat`]```cpp25 行未改动while(c<'0' or c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0' and c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}return x*f;}```::::7 行未改动}```::::### 重载运算符::::info[代码]```cppstruct node{int w,id;bool operator<(const node& other) const {// 从小到大return w<other.w;}};```::::### 去重::::info[代码]```cppsort(a.begin(),a.end());a.erase(unique(a.begin(),a.end()),a.end());```::::### 快速幂 [P1226 【模板】快速幂](https://www.luogu.com.cn/problem/P1226)### 离散化::::info[代码]4 行未改动if(b[i]!=b[i-1])c[b[i]]=++ii;/*c[i]表示的是值为i的数离散化后的数*/for(int i=1;i<=n;i++) b[i]=c[a[i]];/*b[i]是离散化后的数组*/```STL 版的:```cppsort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());```::::### tarjan(连通性) [P2863 [USACO06JAN] The Cow Prom S](https://www.luogu.com.cn/problem/P2863)[博客园](https://www.cnblogs.com/yanyiming10243247/p/9294160.html)42 行未改动### 2-SAT [P4782 【模板】2-SAT](https://www.luogu.com.cn/problem/P4782)::::info[记住就行]我们求解 2-sat 的过程为:1. 建图,将限制 若 p,则 q 的点连接起来。2. 缩点。3. 如果一个状态的正负两个点再同一个 scc 中则无解。4. 否则一定有解;对每个变量取所在分量 scc 标号较小的对应状态::::