
CF日常
文章平均质量分 77
做不完的ACM
加油,努力
展开
-
CF 910A DP
题目链接:http://codeforces.com/contest/910/problem/A题意:给出长度为n的01串,1可以走,0不可一,保证串第一个位置和第n个位置为1,每次可以走1-d步,比如你在x处,你可以走到x+1 ~ x+d之间任何一个为1的地方。DP写法1:复杂度O(n*d),很常规的两层for#include <bits/stdc++.h>using names...原创 2018-03-13 11:53:05 · 238 阅读 · 0 评论 -
Codeforces 451E(生成函数or容斥原理)
题目链接:http://codeforces.com/contest/451/problem/E题意:给定N种花,每种花有Fi朵,现在要取M朵花,问有多少种方案。思路:母函数或者容斥定理,当然,学过数学竞赛的应该知道结论,怎么用容斥定理去做。我更倾向于用母函数去做,虽然方程是一样的,但是感觉后者好理解一些。 母函数 : (1+X^1...+X^f1)*(1+X^1...+Xf2)*...(1...原创 2018-03-22 00:00:35 · 648 阅读 · 0 评论 -
Codeforces 957C二分
题目链接:http://codeforces.com/problemset/problem/957/CC. Three-level Lasertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn atom of element X can exi...原创 2018-03-27 12:16:59 · 511 阅读 · 0 评论 -
Codeforces 710C Magic Odd Square
题目链接:http://codeforces.com/problemset/problem/710/CC. Magic Odd Squaretime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFind an n × n matrix ...原创 2018-04-07 12:44:57 · 267 阅读 · 0 评论 -
Codeforces 710E Generate a String DP
题目链接:http://codeforces.com/problemset/problem/710/E E. Generate a Stringtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputzscoder wants to ge...原创 2018-04-07 12:48:52 · 186 阅读 · 0 评论 -
Codeforces712D 前缀和优化DP
题目链接:http://codeforces.com/problemset/problem/712/DD. Memory and Scorestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMemory and his friend Lexa ...原创 2018-04-07 12:52:56 · 366 阅读 · 0 评论 -
Codeforces 967A Mind the Gap
A. Mind the Gaptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThese days Arkady works as an air traffic controller at a large airport. He controls...原创 2018-04-30 20:16:41 · 215 阅读 · 0 评论 -
Codeforces 980D 数论
题目链接: http://codeforces.com/contest/980/problem/DSaMer has written the greatest test case of all time for one of his problems. For a given array of integers, the problem asks to find the minimum numbe...原创 2018-05-09 22:47:44 · 515 阅读 · 0 评论 -
Codeforces 980E(树上贪心倍增)
题目链接: http://codeforces.com/contest/980/problem/EE. The Number Gamestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe nation of Panel holds an a...原创 2018-05-09 22:54:33 · 1475 阅读 · 0 评论 -
Codeforces 965D
题目链接:http://codeforces.com/contest/965/problem/DA lot of frogs want to cross a river. A river is w units width, but frogs can only jump l units long, where l<w. Frogs can also jump on lengths short...原创 2018-04-26 23:27:19 · 359 阅读 · 0 评论 -
Codeforces 965E 启发式合并
http://codeforces.com/contest/965/problem/EE. Short Codetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputArkady's code contains nn variables. Each v...原创 2018-04-27 18:42:00 · 374 阅读 · 0 评论 -
CF 980E(树上差分)树状数组
题目链接: http://codeforces.com/contest/980/problem/EE. The Number Gamestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe nation of Panel holds an a...原创 2018-05-18 22:34:24 · 334 阅读 · 0 评论 -
Codeforces961E
题意: 一个剧一共有n季,每季有ai集。问有多少对x,y(x≠y),使得第x季有第y集且第y季有第x集。题解:问题可以转换成对于当前第i个数,区间1~min(a[i], i-1) 有多少个数大于i的,转换成主席树求解。#include <bits/stdc++.h>using namespace std;const int maxn = 2e5 + 7;struct node...原创 2018-05-24 13:37:19 · 275 阅读 · 0 评论 -
Codeforces 990G. GCD Counting
题目连接:http://codeforces.com/contest/990/problem/G题目描述:G. GCD Countingtime limit per test4.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree consist...原创 2018-06-13 20:18:25 · 658 阅读 · 0 评论 -
Codeforces 949C Data Center Maintenance
题目链接:http://codeforces.com/contest/949/problem/C题意:一天有h小时,某公司有N个信息,每个信息给出一个时间,0-h-1, 现在有m个客户,每个客户有2个信息in1,in2,in1!=in2,问选择一个最小的信息集合,将这集合里的信息时间全部往后推一个小时,如果信息时间为h-1,则变成0。求这个最小集合,并且时间改变后,客户2个信息的时间t[in1[i...原创 2018-03-11 20:01:01 · 303 阅读 · 0 评论 -
Codeforces 365C 思维或二分
C. Matrixtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a string of decimal digits s. Let's define bij = si·sj. Find in matrix b ...原创 2018-03-15 23:43:31 · 241 阅读 · 0 评论 -
CodeForces333E Summer Earnings
题目链接:http://codeforces.com/contest/333/problem/E题面:Many schoolchildren look for a job for the summer, and one day, when Gerald was still a schoolboy, he also decided to work in the summer. But as Gera...原创 2018-03-08 22:45:52 · 286 阅读 · 0 评论 -
Codeforces Round #450 (Div. 2) C
题意: 给出n个数的一个排列, 删除排列中一个数, 使record最大, record定义,对于a[i],都有a[j] 题解: 先预处理下最大和次大值mx1[i]表示1~i的最大值,mx2[i]表示次大, 之后遍历数组, 具体看代码。#include using namespace std;const int N = 1E5 + 7;int mx1[N], mx2[N], a[原创 2017-12-13 21:30:11 · 196 阅读 · 0 评论 -
Codeforces Round #450 (Div. 2)B
题意:给出a,b,c 问a/b小数点第几位第一出现c,不出现输出-1题解:直接模拟除法即可。#include using namespace std;const int N = 1E5 + 7;int h[N*10];int main(){ int a, b, c, i = 1; scanf("%d%d%d",&a,&b,&c); a = a - b*原创 2017-12-13 22:15:03 · 188 阅读 · 0 评论 -
Educational Codeforces Round 903E
Educational Codeforces Round 34 (Rated for Div. 2)原创 2017-12-14 19:45:53 · 500 阅读 · 0 评论 -
Codeforces903C
题目链接:http://codeforces.com/contest/903/problem/D题意:给了一个二元关系为 f(x,y)={y−x,0,|x−y| > 1|x−y| <= 1 f(x, y) = \begin {cases} y-x, & \text{$|x-y|$ > 1} \\ 0, & \text{$|x-y|$ <= 1} \end{cases} 给出原创 2017-12-14 20:25:57 · 343 阅读 · 0 评论 -
Codeforces915E Physical Education Lessons
题目链接:http://codeforces.com/contest/915/problem/E题意:初始化区间1~N,全为1,N是1E9级别,Q个操作与询问。对于当前询问输出1~N还有多少个1。操作1:把L-R这段区间全变0操作2:吧L-R这段区间全变1题解:把区间左右端点暴力存在set里, 对于当前l,r在set里二分下找到第一个在他右边的区间。首先不管K=1还是K=2,都原创 2018-01-15 17:57:01 · 615 阅读 · 0 评论 -
带限制的单点线段树
题目链接:http://codeforces.com/contest/920/problem/F题解:因为更新必须是单点更新,每个数变化的次数是一定的,当他变化成2时(需要特殊考虑1),则没必要继续更新,有限制,所以更新不是每次都要到单点。#include using namespace std;#define SZ(X) ((int)X.size())#define pb pus原创 2018-02-03 15:37:45 · 141 阅读 · 0 评论 -
CF920E 补图的联通块数
题目链接:http://codeforces.com/contest/920/problem/E题解:首先2个集合s1,s2,一个用来存当前点,一个用来临时保存。把删除的边存图,设当前访问的点为S点,集合s1里有点,如果S的出边的点(即u,v之间要删边)在s1里,就需要删除,临时存在s2里,然后访问集合s1,这时集合s1剩下的点一定与S在一个块里面,这次的联通快++,然后入队列,当然之前删除的原创 2018-02-03 15:45:24 · 547 阅读 · 0 评论 -
Codeforces918C思维
#include using namespace std;int main(){ string s; cin >> s;int res=0; int n = s.size(); for(int i = 0;i < n;i ++) { int l,r; l=r=0; //l代表目前的左括号数,r代表把?都当成左括号需要的右括号原创 2018-01-30 01:48:31 · 346 阅读 · 0 评论 -
Codeforces946E Largest Beautiful Number
题目链接:http://codeforces.com/contest/946/problem/E题意:给出一个数字找出第一个比他小的数,且其长度为偶数,并且可以构成回文。题解:1:首先长度为奇数时,直接输出(N-1)个9。 2:长度为偶数时,枚举答案串和输入串的lcp,对lcp的下一位进行枚举,然后判断是否合法。#include <bits/stdc++.h>us...原创 2018-03-07 17:03:35 · 376 阅读 · 0 评论 -
Codeforces946B Weird Subtraction Process
题目链接:http://codeforces.com/contest/946/problem/B题意:You have two variables a and b. Consider the following sequence of actions performed with these variables:If a = 0 or b = 0, end the process. Otherwi...原创 2018-03-07 17:07:10 · 309 阅读 · 0 评论 -
Codeforces931F Teodor is not a liar!
题目大意:有一条线段,上面的点被若干条线段覆盖着. Sasha想知道是否存在一个整点被所有的线段覆盖,她每次可以任选一个点,Teodor会告诉她这个点被多少个线段覆盖,但是Sasha不知道有多少条线段.求Sasha最多猜多少次还不知道这个问题的答案. 也就是说,如果你最多猜n次能知道答案,那么输出n-1.如果猜不到答案就输出n.分析:这种题目把图一画,各种情况考虑一下就能做出来了. 什么情况...原创 2018-03-07 17:36:44 · 550 阅读 · 0 评论 -
Codeforces 931E
题意:有一个字符串,可以选择从第K位开始,将[K,len(s)-1]的字符都移到前面去,现在给你一个首字母,你可以再选择一位进行观察,然后猜测这个K的值是多少, 现在要求求出能猜对K的概率是多少。题解:处理出每一个字母开头的第K位是什么字符, 如果这个字符在这个字母中出现的次数为1,那么表示可以通过这一个位置来区分字符串,cnt++,不为一就说明不能区分,那就将上次的计数删除。#include &...原创 2018-03-07 17:38:37 · 220 阅读 · 0 评论 -
Codeforces 940F
题目链接:http://codeforces.com/contest/940/problem/FCF Round #466的最后一题,颇有难度,正解是带修改莫队算法。【题意】给定一个长度为nn的数组aa,并且要求执行qq个操作,有两种不同的操作:①询问一个区间[l,r][l,r]中集合{c0,c1,c2,⋯,c109}{c0,c1,c2,⋯,c109}的Mex,而cici表示数值ii在[l,r][...原创 2018-03-07 17:41:27 · 305 阅读 · 0 评论 -
Codeforces 245H 区间DP容斥
题意:给出一个字符串S(|S| <= 5000), Q个询问(1E6), 每次给出L,R, 问L,R里有多少个回文子串。题目链接:http://codeforces.com/contest/245/problem/H题解:dp[i][j] = dp[i + 1][j] + dp[i][j - 1] - dp[i + 1][j - 1] + can[i][j]. 注意下dp顺序即可。 ...原创 2018-03-15 00:23:06 · 195 阅读 · 0 评论 -
Codeforces 914C
题目链接:http://codeforces.com/contest/914/problem/C题面: 题意:给出一个数(二进制形式),每次将他变成他的二进制表示中1的个数, 问有多少个数可以正好在K此变化成为1。题解:首先用一个数组f记录下f[i]表示i这个数需要f[i]次变换成为1, 则有递推f[i] = f[__builtin_popcount(i)].DP...原创 2018-07-18 16:36:06 · 269 阅读 · 0 评论