随笔分类 - 信息学竞赛
摘要:https://codeforc.es/problemset/problem/1216/D 贪心: 找出最大的a[i],令为t,即假设这个t就是原来的x 然后b[i]=t-a[i]; b[i]表示每个缺了的数量。 最后求一个所有b[i]的最大公约数。 答案就是累加b[i]/gcd 1 #includ
阅读全文
摘要:https://codeforc.es/problemset/problem/1216/C 判断一个矩形是否被另外两个矩形完全覆盖,这题是我是用离散化的方法来做的。 1 #include<bits/stdc++.h> 2 using namespace std; 3 int x[7],y[7],tx
阅读全文
摘要:https://codeforc.es/problemset/problem/1216/B 这题还是贪心,直接排序即可 。 1 #include<bits/stdc++.h> 2 using namespace std; 3 int const N=1000+10; 4 int a[N],n,b[N
阅读全文
摘要:https://codeforc.es/problemset/problem/1216/A 本题直接$O(n)$贪心。 1 #include<bits/stdc++.h> 2 using namespace std; 3 int const N=200000+10; 4 char s[N]; 5 i
阅读全文
摘要:这是一道被离线爆艹的模板题。 你要维护一张无向简单图。你被要求加入删除一条边及查询两个点是否连通。 0:加入一条边。保证它不存在。 1:删除一条边。保证它存在。 2:查询两个点是否联通。 本题解法: 1.lct 2.对操作进行分块,然后维护并查集(需要回到过去)。 时间复杂度$O(m*sqrt(m)
阅读全文
摘要:http://codeforces.com/problemset/problem/1217/E 这题的思路是: 1.首先不能有进位 2.由于要求和最小,所以我们只要选择两个数就可以了。 1 #include<bits/stdc++.h> 2 using namespace std; 3 int co
阅读全文
摘要:http://codeforces.com/problemset/problem/1217/D 这题的思路是构造,我们可以知道颜色最多只需要两种,然后按照dfs的顺序。 1 #include<bits/stdc++.h> 2 using namespace std; 3 int const N=50
阅读全文
摘要:这是一个好题,感觉是noi2018里面最好的题目,考验打表能力,动态规划和对卡特兰数的理解。 1 #include<bits/stdc++.h> 2 using namespace std; 3 int const N=1000000+10; 4 int const mod=998244353; 5
阅读全文

浙公网安备 33010602011771号