https://oi.wiki/graph/mst/#boruvka-%E7%AE%97%E6%B3%95
Nim游戏
https://oi.wiki/math/combinatorics/stirling/
-std=c++14 -Wl,--stack,268435456#include<bits/stdc++.h>
#define int long long
#define PII pair <int, int>
using namespace std;
bool bbb;
bool eee;
signed main() {
cerr << (&eee - &bbb) / 1024.0 / 1024 << '\n';
ios :: sync_with_stdio(0);
cin.tie(0), cout.tie(0);
return 0;
}echo off
:loop
data.exe
t.exe
force.exe
fc t.out force.out
if errorlevel 1 pause
goto loop#include<bits/stdc++.h>
#define int long long
#define PII pair <int, int>
using namespace std;
signed main() {
ios :: sync_with_stdio(0);
cin.tie(0), cout.tie(0);
while(1) {
system("data.exe");
system("t.exe");
system("std.exe");
if(system("fc t.out std.out")) return 0;
}
return 0;
}https://oi-wiki.org/math/number-theory/basic/#%E5%8F%96%E6%95%B4%E5%87%BD%E6%95%B0
Alt+42689α
fact_inv[i] = fact_inv[i - 1] * i % mod;
fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;★
//vector 去重方法
vector <int> v;
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());link 是关键字
(int)v.size()
主函数外不要定义 x, y
★
bool 类型的自增运算(++):对 bool 变量使用 ++x 或 x++ 现在是语法错误(此前在 C++14 中虽已弃用但仍可编译)。
★
如果二分的范围中有负数,那么(l+r)/2是否会错?
整数除法行为?:在 C++、Java 等语言中,(l + r) / 2 对负数是?向零取整?(如 (-5 + 2) / 2 = -1),而数学期望的“下取整中点”可能是 -2,导致区间收缩方向异常。
?死循环风险?:若边界更新用 l = mid 且 mid 计算偏高(如 l=-1, r=0 时 mid = -1),可能无限循环。
★
unqiue(a + 1, a + n + 1, cmp);
这里的 cmp 是比较等于的自定义函数。
复制时注意删掉 cmp ,不会报错。
★
int u = q.top().p, udis = q.top().dis;
q.pop();
if(udis > dis[u]) continue;
Dijkstra不加这句话复杂度就是假的
★
const long long M = 1e17 + 5;
会引发精度问题,大型比赛建议写成
const long long M = 100000000000000005;
或
const long long M = 1e17l + 5; //long double 只支持到18为左右,慎用!
★
set结构体自定义排序方法:
struct Node {
int x, y;
} ;
struct Node_cmp { //仿函数
bool operator() (const Node &A, const Node &B) const { return A.x < B.x; }
};
set <Node, Node_cmp> st;
注意:这样有个潜在问题,如果有两个元素 x 相同而 y 不同,那么 set 是不会放进去第二个元素的!
一定要保证所有元素两两都是大于或小于的!pb_ds 入门到入土:https://www.cnblogs.com/redacted-area/p/18063265
https://www.bilibili.com/video/BV1i5NneQEEL/
OI大事记:https://www.luogu.com.cn/paste/n2j52cs0
讲反演的好博客:https://www.luogu.me/article/998kttnc
关于 pollard-rho: https://www.luogu.com.cn/discuss/987299 https://www.luogu.com.cn/article/ezjcoth4
平衡树单log启发式合并的trick:https://www.luogu.me/article/jnfozglu
有可能你这辈子打的广义SAM都是错的:https://www.luogu.com.cn/discuss/322224
复杂度分析AI:https://www.timecomplexity.ai/
很好的讲SATT的文章:https://f7487.blog.uoj.ac/blog/7490
合成:https://craft.murasame.site/
一些搬运脚本的博客:https://www.cnblogs.com/Wy-x/articles/19019167
原题机:https://cpret.online/ https://yuantiji.ac https://chat.cpgraph.top/
『』「」<>《》【】{}()[]
置顶:
好活共赏
小恐龙:chrome://dino
1、然后输入以下代码,恐龙将变得无敌:Runner.instance_.gameOver=function(){}
2、下面是急速快跑代码,参数可修改:Runner.instance_.setSpeed(20)
3、下面是跳高代码,参数可修:Runner.instance_.tRex.setJumpVelocity(20)
koyso.com
https://www.bilibili.com/video/BV17CYxeLEJW/
-1 1000017 0 0 0 1 0 0 0 6 1 0 0 0 0 0 0 0 999985 1 28 1 0 2 0 0 1
0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
丧尸围城存档
- 网页计数器
- 某科学的超电磁炮格式同款生成器
- 麦块成就生成器
- 首字母缩写查找器
- 梯子
- OIer Space
- 摸鱼器
- DeepL翻译——不是生草机!
- 一个小工具箱
- base64编码/解码转换 +1
- 放大图片工具
- 测试密码强度器
- 数字114514化工具
- :洛谷图床 / Imgbb图床 / Superbed图床 / Imgtu图床
- 洛谷题解站
- 洛谷私信删除脚本
- 洛谷删犇器(悲
- 练习情况题目显示颜色
- 【脚本】Luogu Search AnyWhere By tiger2005
- 洛谷主页背景
- :exlg下载地址 / exlg说明书QWQWQWQ / 专贴 / 6.6.0 无法显示解决方法 图解版
- 六 倍 经 验
- 九倍经验!!
- 质数查找和检验
- 文本比较器
- geogebra图形计算器
- demos图形计算器
- graph_editor图论画图工具
- 八聚氧 吸到你爽
- 最水紫题
- StudyingFather的洛谷综合题单
- SPFA的试炼场
- SUPER 快读
- 学习历史的好东西
- 背景图搜索站
- OIERdb
- 排序图像化网站
- IOI官网
- Google 全景地图 qwq
- 冬日绘版入口
- 犇 犇 龙 王 榜
- c++百科全书
- byvoid.com
- 哔哩哔哩
- 孟坤lab实验室
- hackchat 他的指令
- 解决数学问题的好帮手wolframalpha
- 百度
- 百度翻译
- 百度百科
- 伪基百科
- OI-wiki
- 洛谷
- Libre OJ
- Hydro OJ
- JZOJ
- CF
- VJUDGE镜像
- OI大纲
- Eason_AC 的 OI 小技巧
- 如何选择笔记本电脑?
- 破解防沉迷NB
- 临时抱CCF脚
被CCF踢一脚CSP初赛知识点梳理 - RE:从零开始搭建自己的博客
- CF使用手册
- 准备AFO的小盆友看这里
- c++真的是四舍五入吗! StudyingFather亲授
- StudyingFather的题解小妙招
- B站视频插入方式
- KMP学习笔记
- 洛谷词典 +1 +2 +3 +169
- 打表日报
- qq表情以及缩写
- 如何做出一个好的PPT?
- 如何使用Markdown?
- 洛谷官方的 Latex 说明
- Latex 数学公式大全
- Latex 入门
- Katex公式大全
- 咕值介绍
- 二进制与位运算
- vijos的骗分导论(?
- command_block的博客目录(干货)
- 洛谷常见问题 BY Elgo87
- c++如何存档与读档?
- 没有exlg,如何使用这些表情?
- EasyX的介绍
- EGE 库入门
- Microsoft edge 安装 tarpermonkey 出错怎么办?
- CF快速入门
- 隐私已死
- 骗分导论(blog
- 复赛时要记住的 30 句话
- 高中数学全讲
- 某些有用的链接
- 公告整合【新】
- 【搬运】高中数学笔记整理
- 【投稿】Netherite_ingot 的剪切板解密
- generals实用技巧
- 对称作画
- 奇奇怪怪的洛谷题目整合
- 1-100的114514化
- 划动鼠标来出现图片
- StudyingFather的2021冬日绘版实时报道
- Inkyo的洛谷冬日绘版战地记者计划 +2021年冬日绘版报道
- OI之歌(汇总版)
- 考古指南
- 语文课本课文《做干净的奥赛》
- 典例 BY 小糯米
- 段子们 +1 +2 +3 +4 +5 +6
- 偷袭被选入语文课本啦!(?)
- kkk爆照啦(?)
- 人 win 浅谈 npy 的好处
- 洛谷|最大青少年感情交流中心(咕民情感帖收录)
- 阿伟:我的SPFA被卡了啊啊啊啊啊啊
- 愚人节JC指南(?)
- 又是一个宝藏帖子
- ACG台词 合集
- CSP2021游记整合贴
- CSP2022游记整合贴
- 洛谷之光 BY 小糯米
- 洛谷工坊游记—管理员的日常
- Harry Potter的各类咒语合集
- 文文新闻1.0目录
- 文文新闻2.0目录
- Tokyo 2020专用讨论帖
- 考古!史上最早帖子
- 考古时应该注意的一些事情
- 洛谷电视台.jpg
:迷惑代码合集/CSP2021迷惑代码合集/上海 CSP-S 组奇葩代码合集/cz的A+B题解/NOIP2021代码合集/对不起这里才是NOIP2021代码合集
- :关于CCF检查代码中是否存在影响CCF名誉的词汇并传唤选手此事的看法:) / AKCSP的最佳方式 / AKCSP的最佳方式 续集XD / lxl很可怜不要欺负他 进不去?来这 / U K E / U K E 二 世 / U K E 二 世 语 录 / U K E 二 世 t q l % % % / U K E 二 世 t q l % % % 2 / wangyibo201026の名言金句 / 神奇のOJ / whk大佬 /
《两只老虎》/ 迫真大型连续剧《Karry5307:从天上到地下》 / 神贴全在这里 +1 / 自 投 罗 网 / 《上海洛谷网络科技有限公司会在3年内IPO》 / 奇奇怪怪的敏感词检测
-
:猜单词 / 猜单词,不过是中文版 / 猜单词,不过是猜数字 / 猜单词,不过是两个一起猜 / 猜单词,不过是四个一起猜 / 猜单词,不过是八个一起猜 / 猜单词,不过是猜音符
-
: 猫国建设者 / 猫国建设者的作弊码XD
-
:三体2048 / 时间复杂度 2048 / 化学2048 / OIER’s 2048 / 普普通通的2048 / 朝代2048
-
:人生重开普通版 / 人生重开开挂版本 / 人生重开天命版(手机不能玩) / 人生重开人上人版本 / 人生重开爆改版(手机不能玩)
-
:微伞小游戏 / T神游戏集 / c++游戏整合 / gamepix.com全是io游戏! / 颓废用的io games / iogames网站 / 游戏合集 / IO233(IO游戏集合) / yikm.net(单机闯关打类游戏) / 单机创意类游戏 / xingye小游戏合集 / 【投稿】各种放置游戏大全 / 【投稿】各种放置游戏大全2
快读快输
void read(__int128 &x){
int f=1;x=0;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
x*=f;
}
void print(__int128 x){
if(x<0){
putchar('-');
x=-x;
}
if(x>9)
print(x/10);
putchar(x%10+'0');
}https://www.cnblogs.com/HaneDaCafe/p/18409847 或者搜 cyaron
要做的题
AT_kupc2012pr_1 AT_abc287_e B3717 CF38B CF11B CF2A P1019 P1020 P1025 P1026 P1033 P1037 P1058 P1061 P1065 P1076 P1077 P1090 P1091 P1095 P1096 P1135 P1140 P1142 P1158 P1168 P1180 P1188 P1199 P1230 P1233 P1239 P1289 P1290 P1292 P1309 P1434 P1443 P1469 P1531 P1590 P1727 P1746 P1775 P1853 P1865 P1908 P1920 P1932 P1965 P1970 P2005 P2078 P2082 P2181 P2239 P2367 P2280 P2357 P2397 P2440 P3951 P2678 P2719 P2712 P3372 P3375 P3368 P3150 P2580 P3353 P3811 P3903 P4549 P4779 P5635 P1923 P4715 P7318 P7074 P7471 P7910 P7912 P7911 P8306 P9498 P9504 P9473 P9457
输入输出加速:关闭同步流
ios::sync_with_stdio(false);
cin.tie(0);高精度
struct Bight{
int len,a[maxn];
Bight(int x=0){
memset(a,0,sizeof(a));
for(len=1;x;len++) a[len]=x%10,x/=10;
len--;
}
int &operator[](int i){
return a[i];
}
void flatten(int L){//展平
len=L;
for(int i=1;i<=len;i++) a[i+1]+=a[i]/10,a[i]%=10;
for(;!a[len];) len--;
}
void print(){//输出
for(int i=max(len,1);i>=1;i--) cout<<a[i];
}
};
Bight operator+(Bight a,Bight b){
Bight c;
int len=max(a.len,b.len);
for(int i=1;i<=len;i++) c[i]+=a[i]+b[i];
c.flatten(len+1);
return c;
}
Bight operator*(Bight a,int b){
Bight c;
int len=a.len;
for(int i=1;i<=len;i++) c[i]=a[i]*b;
c.flatten(len+11);
return c;
}二分
二分答案(枚举答案,进行验证)
一.分析答案范围(l,r)
l:0,1 r:10的9次方
(1)题目给的范围(2)根据题意分析
二.二分
if(函数名(mid)){
<=mid:l=mid+1
==mid;ans=mid
>=mid:r=mid-1
}
三.验证答案:暴力,贪心归并排序
void px(int l1,int r1,int l2,int r2){
int i=l1,j=l2,k=l1,c[100005];
while(i<=r1&&j<=r2){
if(a[i]<=a[j]){
c[k]=a[i];
k++;
i++;
}
else{
c[k]=a[j];
k++;
j++;
}
}
while(i<=r1){
c[k]=a[i];
k++;
i++;
}
while(j<=r2){
c[k]=a[j];
k++;
j++;
}
for(i=l1;i<=r2;i++){
a[i]=c[i];
}
}线性表(栈,队列,字符串)
特点
首元素只有一个后继,
尾元素只有一个前驱,
其余元素有一个前驱和一个后继。栈:先进后出
数组模拟
int st[100],top=0;
(1)top==0 栈空
(2)top==99
(3)入栈:st[++top]=x;
(4)出栈:top--;
(5)获取:st[top]模板
STL-<stack>
(1)定义:stack<int>名字;
(2)入栈:名字.push(x);
(3)出栈:名字.pop();
(4)获取:名字.top();
(5)检测栈是否为空:
名字.empty(){
空:true
不空:false
}单调栈
for(int i=1;i<=n;i++){
while(!st.empty()&&a[st.top()]<a[i]){
f[st.top()]=i;
st.pop();
}
st.push(i);
}队列:先进先出
数组模拟
(1)定义:int q[100],front=0,rear=-1;
(2)队空:rear+1==front;
(3)队满:rear==100;
(4)入队:q[++rear]=x;
(5)出队:front++;
(6)获取队首:q[front]
(7)获取队尾:q[rear]
(8)求元素个数:rear-front+1;模板
STL-<queue>
(1)定义:queue<int>名字;
(2)入队:名字.push(x);
(3)出队:名字.pop();
(4)获取队首:名字.front();
(5)获取队尾:名字.back();
(6)检测队列是否为空:
名字.empty(){
空:true
不空:false
}
(7)求元素个数:名字.size();双端队列
模板
STL-<deque>
(1)定义:deque<int>名字;
(2)入队{
名字.push_front(x);
名字.push_back(x);
}
(3)出队{
名字.pop_front();
名字.pop_back();
}
(4)获取队首:名字.front();
(5)获取队尾:名字.back();
(6)检测队列是否为空:
名字.empty(){
空:true
不空:false
}
(7)求元素个数:名字.size();
(8)清空:名字.clear();单调队列
for(int i=1;i<=n;i++){
while(!t.empty()&&t.front()+k-1<i){
t.pop_front();
}
while(!t.empty()&&a[t.back()]<=a[i]{
t.pop_back();
}
t.push_back(i);
if(i>=k){
cout<<a[t.front()]<<" ";
}
}迭代器
deque<int>::iterator it=名字;
解引用:
*名字.begin(); 首
*(--名字.end()); 尾后
*名字.rbegin();
*名字.rend();链表
struct node{
int data,nxt;
}List[100];
头指针:int head=1;
链表长度,申请新节点:int tot=0;
(1)查找x在不在链表中?(按值查找)
for(int i=head;i!=0;i=List[i].nxt){
if(List[i].data==x){
return true;
}
}
return false;
(2)查找第P个元素是什么?(按序号查找)
int s=0;
for(int i=head;i!=0;i=List[i].nxt){
if(++s==P){
return List[i].data;
}
}
return -1;
(3)在头节点前面插入
List[tot].nxt=head;
head=tot;
(4)在P节点前插入
int s=0;
for(int i=head;i!=0;i=List[i].nxt){
if(++s==P-1){
List[tot].nxt=List[s].nxt;
List[s].nxt=tot;
}
}
(5)删除链表中值为x的节点
for(int i=head;i!=0;i=List[i].nxt){
if(List[List[i].nxt].data==x){
List[i].nxt=List[List[i].nxt].nxt;
break;
}
}
(6)删除第P个节点
int s=0;
for(int i=head;i!=0;i=List[i].nxt){
if(++s==P-1){
List[i].nxt=List[List[i].nxt].nxt;
break;
}
}
(7)新建节点
List[++tot].data=x;搜索
深度优先搜索(DFS)
方向增量{
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
}
void dfs(int x,int y){
if(x==fx&&y==fy){
sum++;
return;
}
for(int i=0;i<=3;i++){
int nx=dx[i]+x;
int ny=dy[i]+y;
if(nx<1||nx>n||ny<1||ny>m){
continue;
}
if(q[nx][ny]==1){
continue;
}
if(f[nx][ny]==1){
continue;
}
f[nx][ny]=1;
dfs(nx,ny);
f[nx][ny]=0;
}
}广度优先搜索(BFS)
方向增量{
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
}
void bfs(int x,int y){
f[x][y]=1;
a[x][y]=0;
sx.push(x);
sy.push(y);
while(!sx.empty()){
int fx=sx.front();
int fy=sy.front();
sx.pop();
sy.pop();
for(int i=0;i<4;i++){
int nx=fx+dx[i];
int ny=fy+dy[i];
if(nx<=0||nx>n||ny<=0||ny>m||f[nx][ny]==1){
continue;
}
f[nx][ny]=1;
a[nx][ny]=a[fx][fy]+1;
sx.push(nx);
sy.push(ny);
}
}
}树和图
堆(代码为最小堆)
void up(int p){
while(p>1&&a[p]<a[p/2]){
swap(a[p],a[p/2]);
p/=2;
}
}
void down(int p){
int s=p*2;
while(s<=top){
if(s+1<=top&&a[s]>a[s+1]){
s++;
}
if(a[p]>a[s]){
swap(a[p],a[s]);
p=s;
s*=2;
}
else{
break;
}
}
}
void sc(int p){
swap(a[p],a[top]);
top--;
up(p);
down(p);
}链式前向星
//添加一条从u指向v的有向边
void f(int u,int v){
//申请新结点
tot++;
a[tot].to=v;
//头插法建立新链表
a[tot].next=head[u];
head[u]=tot;
}素数筛
埃氏筛
int main(){
cin>>n;
cout<<2<<"\n";
for(int j=2;j<=n/2;j++){
f[2*j]=1;
}
for(int i=3;i<=n;i+=2){
if(f[i]){
continue;
}
cout<<i<<"\n";
for(int j=i;j<=n/i;j++){
f[i*j]=1;
}
}
return 0;
}动态规划
求最长上升子序列
for(int i=1;i<=n;i++){
dp[i]=1;
}
for(int i=1;i<=n;i++){
ma=0;
for(int j=1;j<i;j++){
if(a[j]<a[i]){
ma=max(dp[j],ma);
}
}
dp[i]=ma+1;
m=max(m,dp[i]);
}最大子段和
for(int i=1;i<=n;i++){
dp[i]=max(a[i],a[i]+dp[i-1]);
m=max(m,dp[i]);
}求最长公共子序列
for(int i=1;i<=m;i++){
for(int j=1;j<=m;j++){
if(a[i]==b[j]){
dp[i][j]=dp[i-1][j-1]+1;
}
else{
dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
}
m=max(m,dp[i][j]);
}
}01背包
for(int i=1;i<=n;i++){
for(int j=m;j>=w[i];j--){
f[j]=max(f[j],f[j-w[i]]+z[i]);
}
}完全背包
for(int i=1;i<=m;i++){
for(int j=w[i];j<=m;j++){
f[j]=max(f[j],f[j-w[i]]+z[i]);
}
}多重背包
for(int i=1;i<=n;i++){
for(int j=s;j>=w[i];j--){
for(int k=1;k<=a[i];k++){
f[j]=max(f[j],f[j-k*w[i]]*k);
}
}
}快速幂
递归
int f(int a,int b){
if(b==1){
return a;
}
int t=f(a,b>>1);
t%=p;
t*=t;
t%=p;
if(b&1){
t*=a;
}
return t%p;
}循环
while(b){
if(b&1){
s*=k;
s%=p;
}
k*=k;
k%=p;
b>>=1;
}