CodeForces专题提供CodeForces的最新资讯内容,帮你更好的了解CodeForces。
http://codeforces.com/contest/811 1 水题,两个人有蛋糕,每天互相给,并且每天多给一个。看谁最后给不了。 直接滚动就行。 #include <bits/stdc++.h> using namespace std; int main() { int a[2]; scanf("%d%d",&a[0],&a[1]); int tt=0; in
原题链接: codeforces 840D 大意: 给一个无向连通图,不包含子环,允许回路存在。每个点的权值为 di , di 的值为 1 ,-1 ,0 的一种。现在要求构造一个子图,要求每个点的权值为 -1 或是 该点的度数模 2 为 d[i] 。 不存在则输出-1 Limits: n 3e5 思路: 当时比赛的时候有点乱,没理清楚,题目并不难,但是不是很好打。学习了一个写法。 首先考虑特殊情况
A. Generous Kefa One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get
B. Godsend Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for
C. Leha and Function Leha like all kinds of strange things. Recently he liked the function F(n, k). Consider all possible k-element subsets of the set [1, 2, …, n]. For subset find minimal element in
题意:给你一棵树,根节点是1,每个节点都有一个权值,现在要求出每个节点的结果,结果的定义为从根节点到该节 点(包含)路径上所有点的值的gcd,求解每个点时可以把路径上某一个点的值变为0。每个节点的结果独立计算。 思路:可以直接进行dfs,每个节点用set分别保存它到根节点不取每一个点的gcd,比如路径为1 - 2 - 3 - 4,4号节点 保存的set是gcd(a[1], a[2], a[3]),
C. Ilya And The Tree Ilya is very fond of graphs, especially trees. During his last trip to the forest Ilya found a very interesting tree rooted at vertex 1. There is an integer number written on each
题意:给你一个数组,m次操作,每次操作给你个x,把所有数亦或x,每次操作后输出数组的mex值,mex值表示第一个未出现的自然数。 思路: 1. 异或的效果是可以累加的,所以每次操作的x亦或可以叠加起来成X,这样每次操作就是对原数组亦或X。 我们一开始把原数组不存在的数插入到01Trie,现在对原数组进行一次异或操作,则异或之后的a数组的mex值就是 插入 的数组(未出现的值)xor x之后的最小值
http://codeforces.com/contest/842 给定一个区间l到r a到b。、 问你是否存在一个整数 x属于l,r, y属于a-b,他们的比例x/y等于k。 因为x,y是整数,所以并不是连续的。不能通过计算这两个区间的最大斜率和最小斜率然后比较。 枚举一个区间即可。 #include <bits/stdc++.h> using namespace std; /* */ doub
http://codeforces.com/contest/842/problem/C 给定一个树,树上每个点有一定价值。 这个点上的魅力值是 从1到这个点的路径 上的所有点价值的gcd。 你有一个操作,可以选择是否要把其中一个点的价值变成0。也就是不影响他的gcd。可以理解为每次求 一个点的魅力值时,都是独立的(也就是你在求一个点的时候,可以把一个点变成0,再求另一个点的魅力值时,可以选择其他点
传送门:点击打开链接 A. Kirill And The Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kirill plays a new computer game. He came to the potion
B. Arpa and an exam about geometry time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Arpa is taking a geometry exam. Here is the last proble
http://codeforces.com/contest/816 A 模拟,从头到尾就行 给你一个时间。 输出最小的时间差(比当前大),使时间回文 时间很短。60*60*60*24 #include <bits/stdc++.h> using namespace std; char b[6]; int a[6]; bool solve(){ if(a[0]==a[4]&&a[1]==a[
http://codeforces.com/contest/816/problem/C 这个题,看下面的解释就看懂了。 给定一个矩阵,每块都有值,可以一行一行的删除,也可以一列一列的删除,问你最小的删除方法 行多按列删除,列多按行删。 一次删完,找最小的。 #include <bits/stdc++.h> /* 模拟,每次找最小的。 如果行大,就从列开始找, 如果列大,就从行开始删(保证删除的最少
http://codeforces.com/contest/816/problem/E 给定一个物品的 原价格 和现价格,问你如何买能让他在有限花费内物品最多。存在制约关系,比如买3必须买1。 树形dp。设置两种状态,一种是父节点用了打折卡。一种是父亲没有用打折卡。父亲用了二者卡,儿子不一定要用打折卡。(比方说这个打折卡就便宜了一毛钱,而加上那一毛就可以再买一个东西了) ※ 关键是 对树形背包的理
Our bear's forest has a checkered field. The checkered field is an n × n table, the rows are numbered from 1 to n from top to bottom, the columns are numbered from 1 ton from left to right. Let's deno
A. Kirill And The Game time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Kirill plays a new computer game. He came to the potion store where
 Planning time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Helen works in Metropolis airport. She is responsible for creating a departure sc
C. Planning time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Helen works in Metropolis airport. She is responsible for creating a departure
题意:有n+1个城市,从1~n号城市每个城市有一个评委要到0号城市和其他n-1个评委一起工作k天(这k天n个评委都要在),并且要把所有评委送回他原来所在的城市。现在有m个航班,只有从i号城市到0号城市,或者从0号城市到i号城市(航班到达的那天不能工作),问你最少需要花费多少钱。 思路:贪心维护dp1[i] 表示第i天所有评委到达的最小花费,dp2[i]表示第i天所有评委离开的花费. 处理完dp1,