AtCoder Grand Contest 028 Two Abbreviations 答案显然要么为 $-1$ 要么为 $\text{lcm}(n,m)$,判一下就好了。 const int N = 1e5 + 7; int n, m, d; char a[N], b[N]; int main() { rd(n, m), d = ...
题解
AtCoder Grand Contest 029 题解
AtCoder Grand Contest 029 Irreversible operation 最后的字符串一定是所有 W 在 B 前面,于是考虑对应位置下标差之和即可。 const int N = 2e5 + 7; int n, p[N], t; char s[N]; ll ans; int main() { ...
AtCoder Grand Contest 030 题解
AtCoder Grand Contest 030 Poisonous Cookies $ans = \min(a+b+1,c) + b$。 int main() { ll a, b, c; rd(a, b, c); print(min(a + b + 1, c) + b); return 0; } Tree Burning 贪心,...
AtCoder Grand Contest 031 题解
AtCoder Grand Contest 031 Colorful Subsequence 对于每种字符,可以选某一个或者不选,最后去掉空的。 const int N = 1e5 + 7; int n; char s[N]; int main() { rd(n), rds(s, n); map<char...
AtCoder Grand Contest 032 题解
AtCoder Grand Contest 032 Limited Insertion 倒着考虑,每次找到最大的 $i$ 满足 $a_i = i$ 然后删掉,如果不存在则无解。 const int N = 107; int n, a[N], ans[N]; int main() { rd(n), rda(a, n...
AtCoder Grand Contest 033 题解
AtCoder Grand Contest 033 Darker and Darker 怎么 AGC 还有这种垃圾题啊。 const int N = 1e3 + 7; const int dx[] = {1,-1,0,0}; const int dy[] = {0,0,1,-1}; int n, m, d[N][N], ans; queue<pi&g...
AtCoder Grand Contest 034 题解
AtCoder Grand Contest 034 Kenken Race 分 $c < d$ 和 $c>d$ 讨论一下,后者合法多一个限制:存在 $i \in [b,d]$ 满足 $i-1,i,i+1$ 都是空的。 const int N = 2e5 + 7; int n, a, b, c, d; char s[N];...
AtCoder Grand Contest 035 题解
AtCoder Grand Contest 035 XOR Circle 随便判一下。 const int N = 1e5 + 7; int n, a[N]; int main() { rd(n), rda(a, n); map<int, int> c; for (int i = 1; i <= n; i++) ++c[a...
AtCoder Grand Contest 036 题解
AtCoder Grand Contest 036 Triangle 考虑 $\triangle (0,0)(x,n)(n,y)$ 的面积为 $n^2 - xy$,找到最小的 $n$ 满足 $n^2 \ge S$,设 $k = n^2 - S$,有 $0 \le k \le 2n-1$。 若 $k < n$,则 $\triang...
AtCoder Grand Contest 040 题解
AtCoder Grand Contest 040 >< 对于每个 <<...<>>...> 必然是两端 $0$,往中间 $+1$。 头尾特判一下。 const int N = 5e5 + 7; int n; char s[N]; ll ans; vector<pair<char,...