07 2019 档案
摘要:A. Vasya and Book 简单的取余运用。 B. Vova and Trophies 对于每一个$S$在的位置,二分出它的最大连续前缀$lenLeft$和最大连续后缀$lenRight$。 1. 如果除了这两块前缀以外没有别的$G$了,只需把右边的最后一个移到中间来,用$lenLeft +
阅读全文
摘要:A. Minimizing the String 很明显,贪心之比较从前往后第一个不一样的字符,所以可以从前往后考虑每一位,如果把它删除,他这一位就变成$str[i + 1]$,所以只要$str[i] str[i + 1]$,删除后一定是最优的。 cpp include include includ
阅读全文
摘要:A. Diverse Substring 找普遍性(特殊解即可)。 最简单的便是存在一个区间$[i, i + 1] (1 include include using namespace std; const int N = 1010; int n; char str[N]; int main(){
阅读全文
摘要:A. Vasya and Chocolate 模拟题。数据会爆$int$,要开$long$ $long$ B. Vasya and Isolated Vertices 考虑最小时,两两连边,答案为$max(n 2 m, 0)$ 考虑最大时,除了$m$为$1或0$特判以外,每次尝试用最多的边拓展一个点
阅读全文
摘要:A. Vasya And Password 模拟题,将所缺的种类依次填入“出现次数$ 1 $”的位置,替换掉Ta即可。 cpp include include using namespace std; const int N = 110; int n, a[N], cnt[N], tot = 0,
阅读全文
摘要:A. Function Height 由于只能提升$x$为奇数的点,每个三角形的底一定为$2$, 则要求我们求: $2 (h_1 + h_2 + … + h_n) / 2 = k$,使$max(h_1, h_2…h_n)$最小。 则应使每个$h$平摊重量,答案即为$\lceil n/k \rceil
阅读全文
摘要:A. Palindromic Twist 由于必须改变。所以要使$a[i] = a[n i + 1]$。 要么同向走,但必须满足之前的$a[i] = a[n i + 1]$。 要么相遇,必须满足两字符相差$2$的距离。 cpp include include include include usin
阅读全文
摘要:A. Death Note 简单模拟,可用$\%$和 $/$来减少代码量 cpp include include using namespace std; const int N = 200010; int n, m, a[N], cnt = 0, tot = 0; int main(){ scan
阅读全文
摘要:A. Game Shopping 按照题意模拟既可。 D. Relatively Prime Graph 暴力可行。 任取两个正整数,他们互素的概率为$6/π^2$。 "参考" "维基百科:" In a sense that can be made precise, the "probability
阅读全文