- 博客(11)
- 收藏
- 关注
原创 endless walk
https://atcoder.jp/contests/abc245/submissions/me 无向图,如果从这个点出发能一直走下去则为好点,输出图中这种点的个数 倒着拓扑排序,不断更新出度,删除出度为0的点,剩下的全是好点 #include<bits/stdc++.h> using namespace std; const int maxn=2e5+7; vector<int> g[maxn]; int deg[maxn]; int main() { int n,m;
2022-03-30 19:02:59
200
原创 ATC245 E - Wrapping Chocolate
https://atcoder.jp/contests/abc245/tasks/abc245_e n块巧克力,m个盒子,一个盒子装一块巧克力 能否把所有的巧克力都装进去 把盒子和巧克力都从大到小排序 multiset是可以有重复的元素 把大于巧克力宽 的盒子长放进multiset里 用二分lower_bound查找>=巧克力长的盒子,然后erase掉 #include<bits/stdc++.h> using namespace std; const int maxn=2e5+25;
2022-03-28 20:32:24
240
原创 D.K-good
https://codeforces.com/contest/1656/problem/D 看n是否是让k个数分别%k的和,输出任意符合的k 构造题 n=(1+k)k/2+mk(m>=0) 2n=(1+k)k+2mk 2n=k(2m+k+1) k是奇数的话,2m+k+1就是偶数 k是偶数的话,2m+k+1就是奇数 也就是构造把2*n分解成奇数和偶数乘积 #include<bits/stdc++.h> using namespace std; typedef long long ll; in
2022-03-25 23:25:24
528
原创 C. Make Equal With Mod
https://codeforces.com/contest/1656/problem/C 问数组能否经过模若干个数达到相等 如果没有1,则一定是可以的 类似于0 2 3 4 从大到小一次模,最后全等于0 如果有1且存在差为1,则最后一定是有不同的 #include<bits/stdc++.h> using namespace std; const int maxn=1e5+25; typedef long long ll; const int inf=0x3f3f3f3f; int a[max
2022-03-25 20:39:59
467
原创 codeforces round#125 C. Bracket Sequence Deletion
https://codeforces.com/contest/1657/problem/C 注意题目中的最短前缀,而且比较特殊的是只有两个字符‘(’和‘)’ 如果a[i]==’)’,那么到下一个‘)'就是最短回文前缀,因为无论中间夹杂奇数个‘)’还是偶数个都是回文的 因为要求最短前缀,所以如果a[i]==’(’,那么最短的情况无非是两种()和((,一个是正则的一个是回文的,都符合,所以只要碰到(,就可以操作数++然后跳 #include<bits/stdc++.h> using namespac
2022-03-24 12:03:40
676
原创 L2-025 分而治之 (25 分)
单纯模拟会超时 把问题变换一下 把要摧毁的城市的vis都标记为1 如果路的两端的城市都没被摧毁,则不符合题中的剩下的所以城市都孤立无援 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=1e4+6; int f[maxn]; int n,m; int vis[maxn]; int find(int x) { while(x!=f[x]) x=f[x];
2022-03-23 19:23:43
130
原创 L2-020功夫传人
测试点1是祖师爷就是得道者的情况 #include<bits/stdc++.h> using namespace std; const int maxn=1e5+7; const int inf=510; double a[maxn]; int head[maxn],cnt=0; double z,r; int n; double ans=0; struct node { int v; double w; int next; }E[maxn*2]; double w
2022-03-17 15:22:00
113
原创 l2-013 红色警报
每次都要初始化 然后并查集统计连通块的数量 如果重新连然后统计一遍之后,数量比last多1,或不变都是不改变连通性的 用cnt来统计陷落的城市 #include<bits/stdc++.h> using namespace std; const int maxn=5e4; const int inf=510; int vis[inf],f[inf]; int cnt=0; typedef pair<int,int> PII; void init() { for(int i=0
2022-03-15 21:36:27
105
原创 l2-012关于堆的判断
//第一次读入数字用的是字符串,负数会错 #include<bits/stdc++.h> using namespace std; const int maxn=5e4; const int inf=1e4; int heap[maxn]; int pos[maxn]; int x[maxn]; //没有处理负数 void siftup(int i) { if(i==1) return; while(i>1&&heap[i]<heap[
2022-03-15 21:18:41
410
原创 codeforces#775 B.Game of Ball Passing
将a排序 max->x1->max->x2>max->x3…->max; 1只球可以使max多消耗一次 令sum=a1+a2+a3+…a(n-1); 如果sum>=max ans=1; 如果sum<max ans=max-sum; 有个特例是全0 #include<bits/stdc++.h> using namespace std; const int maxn=1e5+7; const int inf=0x3f3f3f3f; typedef l
2022-03-06 20:47:31
647
5
原创 L3-005垃圾箱分布
https://pintia.cn/problem-sets/994805046380707840/problems/994805052131098624 1.dij求到垃圾箱到每个点的最短距离 2.优先选择最短距离最大 3.其次平均距离小 4.再数字小 #include<bits/stdc++.h> using namespace std; const int maxn=1e5+7; const int inf=0x3f3f3f3f; int head[maxn],e[maxn],ne[max
2022-03-06 12:58:02
249
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人