文章分类 -  OI题目

上一页 1 2 3 4 5 6 7 8 ··· 12 下一页
摘要:/* 极差是 两个数的最大值 1.>>>>> <><><><> <<<<<< / <<<<<<< <><><><><> >>>>>> 2*(max(L1,L2)-com_lenth) 2.>>>> <><><> >>>>>> 2*|L1-L2| 3.& 阅读全文
posted @ 2023-10-05 16:19 JMXZ
摘要:/* n个数 1/-1 求最少修改几个数 满足 ai..>=0 且 ai*..==1 n/=2 是 -1 最多的个数 cnt(-1个数) 修改后一定是偶数 1.cnt偶数+cnt<=n/2 -> 0 2.cnt偶数+cnt>n/2 ->cnt-n/2+(cnt-n/2 %2 ==1)*1 3.cnt 阅读全文
posted @ 2023-10-05 00:28 JMXZ
摘要:/* :::给定 L<=R 求最大的 |ai-bi|+.... 100位 一定是贪心 否则数组 炸裂 观察 样例就可以发现 构造答案 1.n!=m 补成m 前缀照抄 string/char -> reverse string->push_back() 2.首位不变 |A0000000-B999999 阅读全文
posted @ 2023-10-04 23:55 JMXZ
摘要:/* :::每次删一条边 分裂的两棵子树 重心 编号总和 pre: 1.重心:去掉点及所连边后 |最大子树|<=[n/2](floor) 且只有1/2个重心 且一定是子父节点 2.重心一定是最大子树最小的点 (只去掉了一个点) 3.重心一定在 本结点或 重儿子的子树上 4.n-sizx<=[n/2] 阅读全文
posted @ 2023-10-04 01:30 JMXZ
摘要:/* 最小值最大-> 二分 -> 右偏 r=mid-1 l<r 首先考虑最简单情况 sort(a) k<=n 则倒叙 加上 ai 若人不符合 return0 k>n >>因为1~k 所以连续两次操作 -1 >>ai'=ai+p1-p2+p3-p4....(-1)^(t-1)pt 操作奇数次 一定增 阅读全文
posted @ 2023-10-03 09:32 JMXZ
摘要:/* 最小生成树的 sum唯一 但形状不一定唯一(边长相同) 若边长唯一 则 tree 唯一 */ #include<cstdio> #include<iostream> #include<algorithm> #include<cmath> //#include<queue> //#include 阅读全文
posted @ 2023-10-01 01:50 JMXZ
摘要:RMQ 模板题 /* */ #include<cstdio> #include<iostream> #include<algorithm> #include<cmath> //#include<queue> //#include<vector> #include<bits/stdc++.h> #de 阅读全文
posted @ 2023-09-30 01:35 JMXZ
摘要:换根 dp[v]=dp[x]+siz[1]-2*siz[v]; /* 从一棵树中选取 一个结点 使 所有 点上权值 * dis 最短 */ #include<cstdio> #include<iostream> #include<algorithm> #include<cmath> //#inclu 阅读全文
posted @ 2023-09-29 16:30 JMXZ
摘要:/* */ #include<cstdio> #include<iostream> #include<algorithm> #include<cmath> //#include<queue> //#include<vector> //#include<bits/stdc++.h> #define l 阅读全文
posted @ 2023-09-29 11:50 JMXZ
摘要:求出重心+节点到重心距离 /* Çó³öÊ÷µÄÖØÐÄ + ¼ÆËã³öÿ¸ö½Úµãµ½ ÖØÐĵľàÀë */ #include<cstdio> #include<iostream> 阅读全文
posted @ 2023-09-29 08:22 JMXZ
摘要:n个节点的树 每个节点都有p[] 代价 问 相连两点 至少选一个 m 个询问 每次强制规定 两个节点 0/1 求最小代价/ -1 /* 暴力 每次都重置 不合法状态 n^2 预处理+每次都重新 从深度最大的开始跳 n^2 预处理 加上 预处理出 u->root 1 之间 最小的代价 f[x][0/1 阅读全文
posted @ 2023-09-28 10:59 JMXZ
摘要:n 个活动 之间有偏序关系 至少在 其 后 s[] 时间后做 + 每个人物不晚于s[]时间 问最早的时间 拓扑排序+排序时递推 取最大值 /* 4 10 3 1 2 3 4 1 2 5 2 4 2 3 4 4 1 6 3 8 */ #include<cstdio> #include<iostream 阅读全文
posted @ 2023-09-27 15:48 JMXZ
摘要:/* 启发式搜索就是 评估函数 防止拓展不必要的 分支 选:直接加入res + dfs 不选:若后面最好的都 无法 > ans pass 反之 就继续搜索 */ #include<cstdio> #include<iostream> #include<algorithm> #include<cmat 阅读全文
posted @ 2023-09-24 17:28 JMXZ
摘要:/* sum[i]-sum[pre[i]]>=sum[pre[i]]-sum[pre[pre[i]]] sum[i] 一定满足 -> sum[i]>= 2*sum[pre[i]]-sum[pre[pre[i]]] =val(i) 换言之 只要满足 sumi>=RHS就一定是 不减的合法区间 设dp[ 阅读全文
posted @ 2023-09-23 22:37 JMXZ
摘要:/* ai<aj i</>j put in stack ak<ai<aj i<j<k i,j 不能在一起 -> add i,j 二分图判断奇环 col[i] 的颜色 模拟 1 2 3 4 :::若a[i]<t1/2 就一直删除直到 降序排序 */ #include<cstdio> #include< 阅读全文
posted @ 2023-09-23 10:48 JMXZ
摘要:/* dp[i][j][0]->前i个阶段 共申请j次 当前 i状态 换1/不换2 f[][]->0x3f->floyd memset dp 0x3f dp[1][0][0]=dp[1][1][1]=0 (期望*道路长(0)) dp[i][j][0]=min(dp[i-1][j][0]+f[ci-1 阅读全文
posted @ 2023-09-22 20:51 JMXZ
摘要:/* 结论显然 if(lcaa==z) cout<<n-jump(x,lcaa)-jump(y,lcaa)<<'\n'; else if(in(x,z)&&in(y,z)==0) cout<<siz[z]-jump(x,z)<<'\n'; else if(in(x,z)==0&&in(y,z)) c 阅读全文
posted @ 2023-09-22 20:37 JMXZ
摘要:/* 因为 f()过大可以等效替代 -》 dis[i] : %x 的最小值 因为从0开始,而且 ai +(0~x-1) 会有重边 所以可以边出队 边扩展 输入后 spfa 同时 拓展->最短路 a[]_min 是最好的mod因为点数少,边数也少 a[]_min*a[]_min */ #include 阅读全文
posted @ 2023-09-22 20:36 JMXZ
摘要:/* ax+by+cz 有多少种可能 单变量思想 将 x单独独立出来 -> -y+ -z 可以由x部分代替 ->dp[i] %x==i 的最小楼层 dp[i+y]=dp[i]+y 但是推到方向不是单向 可能由更小的推导出来 ->spfa x==1|| ans=h (h-dp[])/h+1 -> dp 阅读全文
posted @ 2023-09-17 16:08 JMXZ
摘要:/* dp[i]=max(dp[j]+(dis<=tim))在 第i只老鼠 前 最多可以打多少只老鼠 */ #include<cstdio> #include<iostream> #include<algorithm> #include<cmath> //#include<queue> //#inc 阅读全文
posted @ 2023-09-17 16:08 JMXZ

上一页 1 2 3 4 5 6 7 8 ··· 12 下一页