CF1146 Forethought Future Cup Elimination Round Tutorial 叮,守夜冠军卡 https://codeforces.com/blog/entry/66639 B 有一个串\(s\),生成了一个新串\(t=s+s'\),\(s'\)是\(s\)去掉所有'a'之后的串,给出\(t\),求\(s\) 如果只看不是'a'的数量也只有最多一个位置满足条件,直接判一下这个位置即可. https://codeforces.com/contest/1146/s…
Forethought Future Cup - Elimination Round 窝也不知道这是个啥比赛QwQ A. Love "A" 给你一个串,你可以删去若干个元素,使得最后a的个数严格大于一半.求最大串长. #include<iostream> #include<cstdio> #include<cstring> using namespace std; char s[55];int v=0,n; int main() { scanf(&q…
A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;} int gcd(int n,int m){return m==0?n:g…
https://codeforces.com/contest/1146/problem/D 题意 有一只青蛙,一开始在0位置上,每次可以向前跳a,或者向后跳b,定义\(f(x)\)为青蛙在不跳出区间[0,x]能跳到多少个不同的位置上,计算\(\sum^m_{i=0}f(i)\) 题解 计算点贡献,计算有多少个区间包含i即i的贡献,设d[i]为走到i经过的最大的点,假如i点能走到,那么包含他的区间就是[d[i],d[i]+1,d[i]+2,...,n] 裴蜀定理有\(ax+by=gcd(a,b)\…
https://codeforces.com/contest/1146/problem/C 题意 一颗大小为n的树,每次可以询问两个集合,返回两个集合中的点的最大距离,9次询问之内得出树的直径 题解 求树的直径:先找到一个点a,找到离他最远的一个点b,最后找到距离b最远的点c,b和c之间的距离就是树的直径 先询问离1最远的距离,然后二分找到这个点a,然后询问a的最远距离 代码 #include<bits/stdc++.h> #define fk fflush(stdout) using nam…
1146C Tree Diameter 题意 交互题.有一棵 \(n(n\le 100)\) 个点的树,你可以进行不超过 \(9\) 次询问,每次询问两个点集中两个不在同一点集的点的最大距离.求树的直径. 题解 和 GXOI2019旅行者 基本类似,二进制分组,对于每一位,编号当前位为 \(0\) 的分到一组,当前位为 \(1\) 的分到另一组.最大询问次数为 \(\log 100 = 7\) code #include<cstdio> int v1[105],v2[105]; int mai…
A:开场就读错题.读对了之后也没啥好说的. #include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000010 #define N 100010 char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=g…
题目链接 题目大意 给你n堆石子(n为偶数),两个人玩游戏,每次选取n/2堆不为0的石子,然后从这n/2堆石子中丢掉一些石子(每一堆丢弃的石子数量可以不一样,但不能为0),若这次操作中没有n/2堆不为0的石子则输 题目思路 本来以为是nim博弈打sg表什么的,结果其实是一个思维题 结论:如果最小堆的数量小于等于n/2则,先手胜,否则后手胜 我们考虑最小堆数量超过n/2的情况.那么此时先手不管如何选取,都会选到一个最小堆,由于要求每轮取得石子数量大于0 ,那么最小堆的石子数必然会减少,而且此时取完…
A. Is it rated? time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to a…
A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to a…