
解题报告
文章平均质量分 65
squee_spoon
这个作者很懒,什么都没留下…
展开
-
Codeforces VK Cup 2017 - Round 2
A. Voltage Keepsake二分答案。B. Volatile Kite把问题转换为求每个点到相邻2点组成的线段的距离。C. Vulnerable Kerbals这题有点意思。我们可以推出这样的结论,当前缀的积(mod m)与m互质时,添加一个数,前缀积可以转换为所有数;但是当前缀的积(mod m)与m的最大公约数为gcd时,添加一个数,只能转换为gcd的倍数。所以策略是先转化为与m的最大公原创 2017-04-17 09:20:43 · 684 阅读 · 0 评论 -
Codeforces CROC 2016 - Elimination Round
C. Enduring Exodus从左到右枚举人住的房间,牛住的房间不断往后推。#include <cstdio>#include <iostream>#include <algorithm>using namespace std;char str[100010];int Next[100010];int calc(int pos,int l,int r){ return max(r原创 2016-03-21 21:17:44 · 390 阅读 · 0 评论 -
Codeforces IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2)
C. Bear and Up-Down当不满足要求的数超过4个的时候,肯定是无解的,否则用每个数和这4个数交换,然后check。。比赛的时候写了很繁琐的分类讨论,竟然没挂。。#include <bits/stdc++.h>#include <unordered_map>#define ll long long using namespace std;int a[150010];int err[1原创 2016-03-21 21:43:31 · 398 阅读 · 0 评论 -
Codeforces VK Cup 2016 - Round 1 (Div. 2 Edition)
A. Bear and Reverse Radewoosh 按要求计算一下即可。#include <bits/stdc++.h>#define ll long longusing namespace std;int p[111];int t[111];int main(){ int n,c; cin>>n>>c; for(int i=1;i<=n;i++){原创 2016-04-01 13:24:39 · 25415 阅读 · 0 评论 -
Codeforces Round #343 (Div. 2)
C. Famil Door and Bracketsdp。状态dp(i,j,k)dp(i,j,k),ii表示填充到了第几个括号,jj表示当前左括号比右括号多多少,kk表示当前在那个子串的左边还是右边填充,状态转移见代码。要注意一些情况,比如要保证任何时候前缀的左括号不少于右括号,后缀的右括号不少于左括号。还有当n=mn=m时,判断子串的合法性。#include <bits/stdc++.h>usin原创 2016-02-22 16:28:36 · 354 阅读 · 0 评论 -
Codeforces Round #344 (Div. 2)
C. Report注意到每次排序的区间都是某个前缀,如果先排序了短前缀,再排序长前缀,前面的那次排序可以不用做。所以单调栈维护递减序列,排序一次最长前缀,然后逐个视情况(升序还是降序)输出。#include <bits/stdc++.h>#include <unordered_map> using namespace std;#define ll long longint a[200010];in原创 2016-03-06 15:25:41 · 329 阅读 · 0 评论 -
Codeforces 8VC Venture Cup 2016 - Elimination Round
C. Block Towers贪心,先分别尽量用低的高度,标记哪些高度用过了。对于那些冲突的,选一个尽可能低的来用。二分答案也可以,并且还有用公式O(1)O(1)的解法。#include <bits/stdc++.h>using namespace std;#define ll long long bool vis[5000010];int main(){ int n,m; cin>原创 2016-02-18 14:29:35 · 545 阅读 · 0 评论 -
Codeforces Round #341 (Div. 2) CDE
C Wet Shark and Flowers计算sis_i为pp的倍数的概率,当sis_i是pp的倍数时,贡献是4000。然后减去相邻两个数同时为pp的倍数的情况。#include <bits/stdc++.h> using namespace std; #define ll long long int l[100010];int r[100010];int flag[100原创 2016-02-01 19:50:01 · 467 阅读 · 0 评论 -
Educational Codeforces Round 7
C. Not Equal on a Segment预处理找到每个位置开始的最先出现的不同的数。#include <bits/stdc++.h>using namespace std;#define ll long longint a[200010];int diff[200010];int main(){ int n,m; cin>>n>>m; for(int i=1;i<=原创 2016-02-13 17:56:50 · 340 阅读 · 0 评论 -
Codeforces Wunder Fund Round 2016 C D E
这场题目质量比上一场有了显著的提升!C Constellation首先找一个肯定在凸包上的点,比如最左下角的点p0p_0,然后对其他所有点进行极角排序。然后挑出角度最小的点中离p0p_0最近的点p1p_1,还有角度第二小的点中离p0p_0最近的点p2p_2。 题虽然简单,但是比赛的时候手贱写了eps=1e-8挂掉了,如果用eps必须设得非常小(其实直接比较浮点数就好了),因为可以构造出一个角度极小原创 2016-01-30 19:16:44 · 406 阅读 · 0 评论 -
Facebook Hacker Cup 2016 Round 2
Boomerang DecorationCarnival CoinsSnakes and LaddersCostly Labels原创 2016-01-25 21:05:43 · 505 阅读 · 0 评论 -
Codeforces AIM Tech Round (Div. 1) ABD
A Graph and String注意’b’的特殊性,它和其他所有点一定有边,然后去构造/搜索,以及检查答案与给定图是否矛盾。 (比赛时的代码比较挫)#include <bits/stdc++.h> using namespace std; #define ll long long int g[510][510];int g2[510][510];int ac[510];i原创 2016-02-05 16:06:02 · 479 阅读 · 0 评论 -
Codeforces Round #338 (Div. 2) ABCDE
A Bulbs随便模拟下。#include <bits/stdc++.h>using namespace std;#define ll long longbool vis [111];int main(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++){ int x; cin>>x; whi原创 2016-01-10 14:37:21 · 410 阅读 · 0 评论 -
Codeforces Round #339 (Div. 1) ABC
A Peter and Snow Blower这题没什么意思,就是贴下计算几何模板。B Skills首先排序,然后枚举加满的技能的数量。对于每次枚举,用二分计算能把最低级的技能加到多少,取一个总分的最大值即可。写的时候要细心,不然容易出bug。 另外,原本以为加满技能的数量->总分是一个凸函数,写了个三分套二分一直WA。后来把三分作了些修改,当区间小到一定程度时改为枚举过掉了(实际上姿势还是不对的原创 2016-01-16 13:45:03 · 620 阅读 · 0 评论 -
Codeforces Round #334 (Div. 1) ABC
A Alternative Thinking 贪心。从左到右扫,找到最先出现的 和上个字符相同的 字符(连续的11或00)。从这个字符开始,只要它和上个字符相同,就反转,再往后考察,反转尽量多,直到字符相异时停止。最后统计一下即可。#include using namespace std;#define ll long longchar str[100010]原创 2015-12-02 12:27:13 · 651 阅读 · 0 评论 -
Codeforces Good Bye 2015 ABCDE
果然到了年末,智商余额不足,无限崩盘。A New Year and Days对着新年日历看一下,分类输出各种情况即可。#include <bits/stdc++.h>using namespace std;#define ll long longint main(){ int n; cin>>n; string q; string str; cin>>q;原创 2015-12-31 13:04:38 · 532 阅读 · 0 评论 -
Codeforces Round #337 (Div. 2) ABCDE
A Pasha and Stick 简单分类讨论。#include using namespace std;#define ll long longint main(){ int n; cin>>n; if(n&1){ cout<<0<<endl; }else{ n>>=1; if(n&1){ cout<<n/2<<endl; }原创 2015-12-27 23:53:01 · 565 阅读 · 0 评论 -
2015.12 hdu 校赛简易题解
01 The Country List暴力for过去。02 Polygon计算几何模板。03 The collector’s puzzle因为盒子能使用多次,排序后取一个最接近的。#include using namespace std;#define ll long long int a[100010];int b[100010];int min3(in原创 2015-12-30 12:41:20 · 615 阅读 · 0 评论 -
Codeforces Round #345 (Div. 1)
AA. Watchmen 只有在和坐标轴平行的线上的两点,两种距离相等。对于重合的点,容斥一下。#include <bits/stdc++.h>#include <unordered_map> using namespace std;#define ll long longunordered_map<int,ll> xx;unordered_map<int,ll> yy;struct poin原创 2016-03-11 21:00:49 · 354 阅读 · 0 评论 -
Educational Codeforces Round 8
D. Magic Numbers看到计数取模就知道用dp了。。 首先把问题转换一下,变成求11~xx范围内满足要求的数有多少。然后设计状态dp(i,j,k)dp(i,j,k),ii表示考察了前i位数,jj表示当前对mm的余数,kk表示小于前缀还是等于前缀(因为我们求的是11~xx,用这种方式来避免数超过xx)。状态转移见代码。 最后就是分别算bb和aa的结果,作差,并检查aa是否合法。#incl原创 2016-02-20 14:45:04 · 444 阅读 · 0 评论 -
Educational Codeforces Round 10
A. Gabriel and Caterpillar 被cha了,不知道为什么。。。B. z-sort 排序以后,贪心从中间往两边取,一定有解的。#include <bits/stdc++.h>using namespace std;int a[1111];int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ c原创 2016-03-26 14:36:45 · 463 阅读 · 0 评论 -
VK Cup 2017 - Round 1
感觉自己代码能力太差了,这场比赛的题都调得很痛苦。。C. Bear and Tree Jumps 对于一棵有根树来说,dfs可以得到每个节点到树根的距离。注意到跳跃距离最大为5,我们可以把距离最多分为五类,同样地,dfs出所有节点到根的距离信息。 我的解法分为两次dfs。第一次dfs可以得到节点1为树根时的距离信息。第二次dfs的目的是“换根”,也就是让每个节点以dfs序作为树根,统计与当前原创 2017-03-23 12:22:27 · 523 阅读 · 1 评论 -
Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined)
这把比赛题目不错,然而打得太挫了。。来写一发题解C. Jon Snow and his Favourite Number基本上是暴力模拟,不过排序和异或要写O(1000)O(1000)的。#include <bits/stdc++.h>using namespace std;const int maxn = 100010;int n,k,x;int cnt[1024][2];int main()原创 2017-02-22 20:25:47 · 546 阅读 · 0 评论 -
Codeforces 8VC Venture Cup 2017 - Elimination Round
C. PolandBall and Forest简单并查集,把相关节点合并即可。#include <bits/stdc++.h>using namespace std;#define ll long longint p[10010]; int a[10010];int find(int x){ if(x!=p[x])p[x]=find(p[x]); return p[x]原创 2017-01-19 22:45:56 · 475 阅读 · 0 评论 -
Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)
比赛的时候过了3题的pretest,结果systest怒跪2题。。rank几乎垫底。但是这场题目确实比较简单。A. Road to Cinema cf特别爱出的二分题。。二分汽油容量,得到一个最小的能跑完的容量,然后在满足这个最小值的车里面找最便宜的。注意可能全程加速也赶不上。#include <bits/stdc++.h>using namespace std;#define ll long l原创 2016-11-20 22:29:18 · 515 阅读 · 0 评论 -
Codeforces Round #361 (Div. 2)
C. Mike and Chocolate Thieves 二分搜。#include <bits/stdc++.h>using namespace std;#define ll long longll a[200000+10];int main(){ for(ll i = 2;i<=200000;i++){ a[i] = i*i*i; } ll r = 1e1原创 2016-07-07 21:23:57 · 374 阅读 · 0 评论 -
Codeforces Round #360 (Div. 1)
B. Remainders Game 如果两个数模所有cic_i结果一样,这两个数的差一定是LCM(ci)LCM(c_i)的整数倍。要使得能够唯一确定一个xmodkx mod k,LCM(ci)LCM(c_i)必须是kk的整数倍。#include <bits/stdc++.h>using namespace std;#define ll long longint c[1000010];bool n原创 2016-07-04 07:56:38 · 343 阅读 · 0 评论 -
Codeforces Round #357 (Div. 2)
D. Gifts by the List 给的图是若干棵树,对每棵树dfs一次即可解决。如果有解,每个人送礼的对象一定是自己的祖先,这在dfs时可以顺便判断。然后就是每个人送礼对象,不能是他祖先送礼对象的真祖先。 每个人的送礼对象如果和父亲的送礼对象相同则不管,若是父亲送礼对象的后代则加到前面去。。#include <bits/stdc++.h>using namespace std;#de原创 2016-06-15 21:21:07 · 371 阅读 · 0 评论 -
something about Educational Codeforces Round 11
这场CF的E、F两题最近才补,拿来说说。比较有意思的是,官方题解给的都不是最优复杂度。。E. Different Subsets For All Tuples 这道题肯定是dp,我的做法是这样的。假设你现在拥有了一个长度为ii的,由mm种字符(或部分)组成的串,然后在最后面添加一个字符’a’,会发生什么呢?我们令’a’具有一般性,用’x’代表除了’a’以外的字符。。比如当前串是”xxaxxxaxx原创 2016-06-27 00:20:24 · 313 阅读 · 0 评论 -
百度之星2016初赛(第二场) -- Astar Round2B
1003 签到题,其实就是输出一个取模后的组合数,需要用到乘法逆元。#include <iostream> #include <stdio.h> #include <cmath> #include <algorithm> #include <string> #include <string.h> #include <set> #include <vec原创 2016-05-22 20:14:16 · 756 阅读 · 0 评论 -
Educational Codeforces Round 13
D. Iterated Linear Function 线性递推。按照我以前的做法,就是矩阵快速幂了。后来我发现,其实这题可以不需要矩阵。递推一下找找规律x2=a∗x1+bx_2=a*x_1+b,x3=a∗a∗x1+a∗b+bx_3=a*a*x_1+a*b+b,x4=a∗a∗a∗x1+a∗a∗b+a∗b+bx_4=a*a*a*x_1+a*a*b+a*b+b…我们可以发现,xnx_n可以看成由两部分原创 2016-06-14 23:39:01 · 420 阅读 · 0 评论 -
Codeforces Round #359 (Div. 1)
A. Robbers’ watch 由于两个数位数加起来不能超过7,枚举可能出现的数,暴力统计,有一些小坑要细心。#include <bits/stdc++.h>using namespace std;#define ll long longll change(ll x){ ll res = 0; ll bit = 1; while(x){ res +=原创 2016-06-24 18:33:54 · 331 阅读 · 0 评论 -
Codeforces Round #358 (Div. 2)
C. Alyona and the Tree dfs。看看哪些节点需要删去,删掉它为根的子树即可。#include <bits/stdc++.h>using namespace std;#define ll long longconst int maxn = 100010;vector<int> sons[maxn];vector<ll> ew[maxn];ll vw[maxn];int ans原创 2016-06-24 18:26:13 · 351 阅读 · 0 评论 -
TopCoder SRM 688
250 这个对子串的操作,可以理解为,把被操作的子串写在纸条上,然后翻转纸条。。仔细分析可以发现,串中匹配的部分,翻转后还是匹配的,所以我们可以把已经匹配的部分去除。去除匹配部分后,剩下的部分肯定是这样的,前面是’)’,后面是’(‘,不可能交替出现两种括号(出现肯定被去掉了)。于是肯定存在只翻转前面一段和后面一段的解。 了解了以上信息,就很容易做了。。具体实现的时候,可以暴力,也可以用栈稍微原创 2016-04-19 22:50:48 · 489 阅读 · 0 评论 -
Codeforces Round #351 (VK Cup 2016 Round 3, Div. 1 Edition)
A. Bear and Colors 模拟一下就完了。#include <bits/stdc++.h>using namespace std;#define ll long long int a[5010]; int cnt[5010];int ans[5010];int main(){ int n; cin>>n; for(int i=1;i<=n;i++){原创 2016-05-14 00:32:56 · 450 阅读 · 0 评论 -
Codeforces Round #349 (Div. 1)
A. Reberland Linguistics 此题重在理解”in a row”的含义。意思是不能有连续相同的两截。正确理解了题意以后,随便dp一下,答案塞到set里面即可。#include <bits/stdc++.h>#include <unordered_map>using namespace std;bool start[4][11111];int main(){ string原创 2016-04-30 18:39:26 · 443 阅读 · 0 评论 -
Google Code Jam 2016 Round 1A
Problem A. The Last Word 贪心。每次加入新的字符时,比较当前字符与生成的串的首字符的大小关系,如果当前字符不小于首字符,加在开头,否则加在结尾。#include <bits/stdc++.h>using namespace std;#define ll long long string str;int main(){ freopen("A-large.in","r原创 2016-04-16 13:49:35 · 764 阅读 · 0 评论 -
Codeforces Round #348 (VK Cup 2016 Round 2, Div. 1 Edition)
A. Little Artem and Matrix 没什么好说的,逆向模拟一下。#include <bits/stdc++.h>#include <unordered_map>using namespace std;#define ll long longint a[10010][5];int ans[111][111];int main(){ int n,m,q; cin>原创 2016-04-25 21:29:32 · 405 阅读 · 0 评论 -
Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] A B C
A A Problem about Polyline 推公式(也有人二分过了)。#include using namespace std; #define ll long longint main(){ int a,b; cin>>a>>b; if(b>a){ printf("-1"); return 0; } if(a==b){原创 2015-09-17 19:35:09 · 522 阅读 · 0 评论 -
2015 ICPC 长春网赛 解题报告
只A了几道水题,还好晋级了。07 The Water Problem 果然是水题,随便模拟一下就好了。为了题解完整性贴出来。#include #include #include #include #include #include using namespace std; int a[1010];int main(){原创 2015-09-13 18:01:59 · 1392 阅读 · 1 评论