- 博客(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
214
原创 ATC245 E - Wrapping Chocolate
https://atcoder.jp/contests/abc245/tasks/abc245_en块巧克力,m个盒子,一个盒子装一块巧克力能否把所有的巧克力都装进去把盒子和巧克力都从大到小排序multiset是可以有重复的元素把大于巧克力宽 的盒子长放进multiset里用二分lower_bound查找>=巧克力长的盒子,然后erase掉#include<bits/stdc++.h>using namespace std;const int maxn=2e5+25;
2022-03-28 20:32:24
261
原创 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+2mk2n=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
541
原创 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
480
原创 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
689
原创 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
141
原创 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
126
原创 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
113
原创 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
423
原创 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>=maxans=1;如果sum<maxans=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
661
5
原创 L3-005垃圾箱分布
https://pintia.cn/problem-sets/994805046380707840/problems/9948050521310986241.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
265
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人