随笔分类 -  《Codeforces题解》

摘要:拿到题就想dp。 状态很好想,dp[i][3] - 0 - 不砍,1 - 向左倒,2 - 向右倒 但是一开始题意读清楚,如果倒的时候有树的位置,那么就不行,并且不能和倒的重叠。 那么转移的时候首先,不砍的话就继承前面所有的。 左边倒的话还要看一下重叠。 #include<bits/stdc++.h> 阅读全文
posted @ 2021-02-15 08:29 levill 阅读(103) 评论(0) 推荐(0)
摘要:非常好的一个题。 如果不是看到dp的tag,我可能真不会往dp去想。 首先状压去枚举肯定不行,因为最多100位。 经过仔细思考之后我得出了一个dp状态。 dp[i][j][k] - 表示a[i]为第j位且余数为k的值。 在验证过后,我发现这个状态很可做。 然后就开始推了,并不是很难推,但是这里有一个 阅读全文
posted @ 2021-02-14 08:38 levill 阅读(57) 评论(0) 推荐(0)
摘要: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 + 阅读全文
posted @ 2021-02-08 17:29 levill 阅读(115) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2021-01-31 16:31 levill 阅读(80) 评论(0) 推荐(0)
摘要:题意注意的是,相反数必定在数组中。 首先很容易可以算出每对相反数的总差值和是一样的,所以d中的差值一定要成对出现。 且,可以发现,对于差值的计算有两种情况。 对于y,计算和-x , x的差值。 当y < x。dis = (x - y) + (y + x) = 2 * x; 当y > x。dis = 阅读全文
posted @ 2021-01-29 09:15 levill 阅读(308) 评论(0) 推荐(2)
摘要: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 阅读全文
posted @ 2020-12-16 21:12 levill 阅读(134) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-11-14 10:42 levill 阅读(92) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-11-02 08:15 levill 阅读(314) 评论(0) 推荐(1)
摘要:学会放弃,可能也需要很大的勇气. 这题磕了蛮久,还是没写出代码。 大致思路已经明白了,记录一下思路吧。 显然,对环进行缩点,但是这里并不是单纯地进行强连通分量的缩点,需要去记录割点。 我们重构树的时候,对于一个环,只需要去放入割点的边。 然后最后去枚举路径上的问题。 第一种做法是dp,这个我没看懂怎 阅读全文
posted @ 2020-10-09 16:48 levill 阅读(107) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-09-29 16:17 levill 阅读(173) 评论(0) 推荐(0)
摘要:A:又又又读错题了~ 如果1和0的个数一样,就删完1. 如果0的个数多,也删完0. 然后1的个数多,那就留下偶数个1即可 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL,int> p 阅读全文
posted @ 2020-09-19 16:34 levill 阅读(133) 评论(0) 推荐(0)
摘要:https://codeforces.ml/gym/101021/problem/1 入门题。 对于交互式题目,就是通过自己询问的结果来判断下一次询问最后得出结果的过程。 对于打印出来的结果,都必须用fflush(stdout)来强制清空 #include<bits/stdc++.h> using 阅读全文
posted @ 2020-09-19 14:41 levill 阅读(859) 评论(0) 推荐(0)
摘要:最近又变怠惰了~~。努力找回状态吧。 A:签到题。 // Author: levil #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<string,int> pii; const int 阅读全文
posted @ 2020-09-12 08:11 levill 阅读(178) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-09-08 16:03 levill 阅读(170) 评论(0) 推荐(0)
摘要: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 = 阅读全文
posted @ 2020-08-31 20:32 levill 阅读(147) 评论(0) 推荐(0)
摘要:A:读错题导致难度飙升。 这里题意是任意两个下标满足条件都能换,那就是个水题了 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef long double ld; typedef pair<LL,int 阅读全文
posted @ 2020-08-13 16:08 levill 阅读(108) 评论(0) 推荐(0)
摘要: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]时,就可以 阅读全文
posted @ 2020-07-12 21:41 levill 阅读(122) 评论(0) 推荐(0)
摘要:A: 边界就是min*max = 0的时候,显然这个时候往后就会继续保持不变. 那么对于没到的情况,暴力去找。到了就直接退出。 至于如何证明这个到0的情况次数不会太多,并不会.. Code: #include<iostream> #include<stdio.h> #include<queue> # 阅读全文
posted @ 2020-05-17 10:26 levill 阅读(146) 评论(0) 推荐(0)
摘要:D:思路:暴力维护优化.用大顶堆来维护,删除元素同时放入两半区间注意的是优先队列默认为最大堆,所以cmp重载,符号需要都和我们想要的结果相反.即(> > = <,> < = >). Code: typedef tuple<int,int,int> ple;//len,l,r struct cmp { 阅读全文
posted @ 2020-05-16 11:08 levill 阅读(124) 评论(0) 推荐(0)