随笔分类 - 《Codeforces题解》
摘要:拿到题就想dp。 状态很好想,dp[i][3] - 0 - 不砍,1 - 向左倒,2 - 向右倒 但是一开始题意读清楚,如果倒的时候有树的位置,那么就不行,并且不能和倒的重叠。 那么转移的时候首先,不砍的话就继承前面所有的。 左边倒的话还要看一下重叠。 #include<bits/stdc++.h>
阅读全文
摘要:非常好的一个题。 如果不是看到dp的tag,我可能真不会往dp去想。 首先状压去枚举肯定不行,因为最多100位。 经过仔细思考之后我得出了一个dp状态。 dp[i][j][k] - 表示a[i]为第j位且余数为k的值。 在验证过后,我发现这个状态很可做。 然后就开始推了,并不是很难推,但是这里有一个
阅读全文
摘要:A:把多余的步数删掉即可。 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> pii; const int N = 1e4 + 5; const int M = 1e4 +
阅读全文
摘要:A:显然保证长度不变是最大的,然后交换1,0,2即可。 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> pii; const int N = 1e5 + 5; const
阅读全文
摘要:题意注意的是,相反数必定在数组中。 首先很容易可以算出每对相反数的总差值和是一样的,所以d中的差值一定要成对出现。 且,可以发现,对于差值的计算有两种情况。 对于y,计算和-x , x的差值。 当y < x。dis = (x - y) + (y + x) = 2 * x; 当y > x。dis =
阅读全文
摘要:A:显然a*kb*kc*k这样构造能满足 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> pii; const int N = 2e4 + 5; const int M
阅读全文
摘要:A:水题: #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL,int> pii; const int N = 2e5+5; const int M = 1e6+5; const LL
阅读全文
摘要:A:签到题,排序之后判断一下即可 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5e6 + 5; const LL Mod = 1e9 + 7; #define INF 1e9 #de
阅读全文
摘要:学会放弃,可能也需要很大的勇气. 这题磕了蛮久,还是没写出代码。 大致思路已经明白了,记录一下思路吧。 显然,对环进行缩点,但是这里并不是单纯地进行强连通分量的缩点,需要去记录割点。 我们重构树的时候,对于一个环,只需要去放入割点的边。 然后最后去枚举路径上的问题。 第一种做法是dp,这个我没看懂怎
阅读全文
摘要:A:签到: #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL,int> pii; const int N = 1005; const int M = 1e6+5; const LL M
阅读全文
摘要:A:又又又读错题了~ 如果1和0的个数一样,就删完1. 如果0的个数多,也删完0. 然后1的个数多,那就留下偶数个1即可 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL,int> p
阅读全文
摘要:https://codeforces.ml/gym/101021/problem/1 入门题。 对于交互式题目,就是通过自己询问的结果来判断下一次询问最后得出结果的过程。 对于打印出来的结果,都必须用fflush(stdout)来强制清空 #include<bits/stdc++.h> using
阅读全文
摘要:最近又变怠惰了~~。努力找回状态吧。 A:签到题。 // Author: levil #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<string,int> pii; const int
阅读全文
摘要:A:签到题 // Author: levil #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<string,int> pii; const int N = 1e5+5; const int
阅读全文
摘要:A:签到题 // Author: levil #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> pii; const int N = 105; const int M =
阅读全文
摘要:A:读错题导致难度飙升。 这里题意是任意两个下标满足条件都能换,那就是个水题了 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef long double ld; typedef pair<LL,int
阅读全文
摘要:C: 将序列排开。 a[1] a[x] a[x+1] a[n]. 可以发现,若满足a[1] < a[n]. 那么对于a[x] > a[1] 和 a[x+1] < a[n] ,将肯定会存在一种情况满足。 然后就可以不断缩减区间数。最后变成a[1] , a[n]. 所以当a[1] < a[n]时,就可以
阅读全文
摘要:A: 边界就是min*max = 0的时候,显然这个时候往后就会继续保持不变. 那么对于没到的情况,暴力去找。到了就直接退出。 至于如何证明这个到0的情况次数不会太多,并不会.. Code: #include<iostream> #include<stdio.h> #include<queue> #
阅读全文
摘要:D:思路:暴力维护优化.用大顶堆来维护,删除元素同时放入两半区间注意的是优先队列默认为最大堆,所以cmp重载,符号需要都和我们想要的结果相反.即(> > = <,> < = >). Code: typedef tuple<int,int,int> ple;//len,l,r struct cmp {
阅读全文

浙公网安备 33010602011771号