Time limit : 2sec / Memory limit : 256MB Score : 700 points Problem Statement Squid loves painting vertices in graphs. There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are pain…
题目链接  agc012 Problem B 题意  给定一个$n$个点$m$条边的无向图,现在有$q$个操作.对距离$v$不超过$d$的所有点染色,颜色编号为$c$. 求每个点最后的颜色状态. 倒过来处理. 记忆化搜索,用$f[x][d]$表示已经对以$x$为中心距离不超过$d$的点进行了染色. 这样保证了对以$x$为中心距离不超过$d$的点进行染色这个行为最多出现一次. 每次对$x$点染色的时候判断是否已经染过色,如果染过就不再染色了. 时间复杂度$O(nd)$ #include <bits…
题意: 给一个包含N个顶点,M条边,无自环和重边的简单无向图,初始每个点颜色都为0,每条边的长度为1,连接着ai,bi两个节点.经过若干个操作, 每次将与某个点vi距离不超过di的所有点染成某种颜色ci,求最终每个点的颜色. 1 <= N, M, Q <= 1e5, 1 <= ai, bi, vi <= N, ai != bi. 0 <= di <= 10, 1 <= ci <= 1e5. 分析: 考虑对操作逆向,f[k][d]表示以k点为中心,dist=d…
AtCoder Grand Contest 012 A - AtCoder Group Contest 翻译 有\(3n\)个人,每一个人有一个强大值(看我的假翻译),每三个人可以分成一组,一组的强大值定义为三个人中第二强的人的强大值.求\(n\)组最大的强大值之和. 题解 这...不是倒着选两个人,正着选一个人构成一组就好了嘛.. #include<iostream> #include<cstdio> #include<algorithm> using namespa…
B - Splatter Painting Time limit : 2sec / Memory limit : 256MB Score : 700 points Problem Statement Squid loves painting vertices in graphs. There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all…
A - AtCoder Group Contest Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement There are 3N participants in AtCoder Group Contest. The strength of the i-th participant is represented by an integer ai. They will form N teams,…
Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement There are 3N participants in AtCoder Group Contest. The strength of the i-th participant is represented by an integer ai. They will form N teams, each consisting of three p…
B - Reversi 题目链接:https://atcoder.jp/contests/agc031/tasks/agc031_b 题意: 给出n个数,然后现在你可以对一段区间修改成相同的值,前提是左右端点的值相同.问最后这n个数有多少种不同的值. 题解: 设dp[i]表示只考虑1~i这段,有多少不同的值.然后对于当前第i位,有两种选择,修改或者不修改,不修改的话就是dp[i-1]:修改的话就是dp[k],这里k表示上一个相同颜色的位置. 注意一下如果i-1和i的颜色相同,当前要跳过,这个时候…
题目传送门:https://agc012.contest.atcoder.jp/tasks/agc012_c 题目翻译 如果一个字符串是好的,那么这个字符串的前半部分和后半部分肯定一模一样.比如\(aa\)与\(bubobubo\)就是好的串,而空串,\(a\)与\(abcabcabc\)以及\(abba\)就不是好的.现在给你一个小于等于\(10^{12}\)的数字\(N\),要你求出一个字符串\(s\),使得这个串的\(2^{len}-1\)个子串里刚好有\(N\)个子串是好的.要求\(le…
题目传送门:https://agc012.contest.atcoder.jp/tasks/agc012_d 题目翻译 给你一排一共\(N\)个球,每个球有一个颜色\(c_i\)和一个重量\(w_i\),如果两个球颜色相同,重量相加不超过\(x\)那我就可以交换这俩个球的位置.如果两个球颜色不同,重量相加不超过\(y\)那我也可以交换这俩球的位置.你可以随心所欲的交换或者不交换,求最后颜色序列的种数.\(N\leqslant 2×10^5;c_i\leqslant N;w_i,x,y\leqsl…