摘要:
C - //// 如果奇数和偶数出现的颜色的最大值相同一边取最大值和一边取次大值,否则两边都选最大值即可。 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=100005; 阅读全文
posted @ 2023-09-27 19:02
Zhou_JK
阅读(14)
评论(0)
推荐(0)
摘要:
C - Triangular Relationship 枚举 \(a\bmod k\) 的值,\(b\bmod k,c\bmod k\) 的值也就确定了,算下贡献就好了。 #include<iostream> #include<cstdio> using namespace std; int n,k 阅读全文
posted @ 2023-09-27 19:02
Zhou_JK
阅读(16)
评论(0)
推荐(0)
摘要:
A - Reachable Towns 现把城市按照 \(x_i\) 排序将第一维去掉。 对于每个联通块,将单调栈将每个联通块中 \(y_i\) 最小的那个存下来。每次新加入一个点 \(i\) 相当于前面的 \(\lt y_i\) 的位置合并成一个联通块。具体地,将单调栈中所有 \(\lt y_i\ 阅读全文
posted @ 2023-09-27 19:01
Zhou_JK
阅读(18)
评论(0)
推荐(0)
摘要:
A - Digit Sum 2 要么是 \(n\) 要么是 \(n\) 的第一位后面加上若干个 \(9\)。 #include<iostream> #include<cstdio> #include<cmath> using namespace std; long long n; int calc( 阅读全文
posted @ 2023-09-27 18:58
Zhou_JK
阅读(14)
评论(0)
推荐(0)
摘要:
A - Diverse Word 如果至少有一个字符没有出现过,只要在原字符串后面加入一个没有出现过的字符中最小的那个字符就好了。 如果所有字符都出现过,找到一个尽量靠后的位置 \(i\in [1,n)\),使得 \(s_i\lt s_{i+1}\),最优字符串将 \(s_i\) 换成 \([i+1 阅读全文
posted @ 2023-09-27 18:58
Zhou_JK
阅读(25)
评论(0)
推荐(0)
摘要:
A - Zero-Sum Ranges 令 \(s_n=\sum\limits_{i=1}^n a_i\),相当于找满足 \(l\le r,s_r-s_{l-1}\) 的点对 \((l,r)\) 的个数,直接搞就完事了。 #include<iostream> #include<cstdio> #in 阅读全文
posted @ 2023-09-27 18:57
Zhou_JK
阅读(25)
评论(0)
推荐(0)
摘要:
A - Fairness 每次操作后 \(a_i-b_i=b_{i-1}-a_{i-1}\),对 \(k\) 的奇偶性讨论一下即可。 #include<iostream> #include<cstdio> using namespace std; int a,b,c; long long k; in 阅读全文
posted @ 2023-09-27 18:57
Zhou_JK
阅读(26)
评论(0)
推荐(0)
摘要:
A - Digits Sum 按题意模拟即可。 #include<iostream> #include<cstdio> using namespace std; const int INF=1061109567; int n; int calc(int x) { int res=0; while(x 阅读全文
posted @ 2023-09-27 18:57
Zhou_JK
阅读(16)
评论(0)
推荐(0)
摘要:
A - Colorful Slimes 2 可以发现,对于连续的一段长度为 \(m\) 的相同的字符,我们可以花费 \(\lfloor \frac{m}{2}\rfloor\) 的代价将它改为符合要求的。 #include<iostream> #include<cstdio> using names 阅读全文
posted @ 2023-09-27 18:56
Zhou_JK
阅读(25)
评论(0)
推荐(0)
摘要:
A - Candy Distribution Again 从小到大贪心,可以发现一定是满足一个前缀,暴力判断就行了。 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=10 阅读全文
posted @ 2023-09-27 18:55
Zhou_JK
阅读(25)
评论(0)
推荐(0)