Codeforces 802I Fake News (hard)】的更多相关文章

原文链接http://www.cnblogs.com/zhouzhendong/p/9026184.html 题目传送门 - Codeforces 802I 题意 求一个串中,所有本质不同子串的出现次数的平方和. $|s|\leq 10^5$ 题解 首先,这一题用 SAM 做就是模板题,比较简单. 但是,本着练一练 SA 的心态,我开始了 SA+单调栈 的苦海. 真毒瘤. 这里讲一讲 SA 的做法,也是经典的做法. SA 闭着眼睛先写了再说. 首先,我们考虑出现次数大于 $1$ 次的子串. 考虑…
Codeforces 802I 题意:统计所有不同子串出现次数的平方的和. 想法:建一个SAM,$Ans=\sum (step[i]-step[fa[i]])*right[i]^2$ #include<cstdio> #include<cstring> #include<algorithm> typedef long long ll; template inline void read(T&x) { x=0;bool f=0;char c=getchar();…
题目大意: 传送门. 给一个n个点的有向完全图(即任意两点有且仅有一条有向边). 每一个点上有$S_i$个人,开始时其中有些人有真金块,有些人没有金块.当时刻$i$时,若$u$到$v$有边,若$u$中第$i%S_u$个人有金块(无论真假),且$v$中第$i%S_v$个人没有金块,则会给$v$中第$i%S_v$个人一个假金块. 假设这样传递了无数次.(即不会再满足上面的条件时) 最后,拥有真金块的人一定可以把金子买出去,而拥有假的人有一半的概率买出去,每买出去一个会给自己的点贡献1的价值. 问题是…
直觉. 一段区间中,肯定是$2$的倍数最多,因为区间长度除以$2$得到的数字最大.但只有$1$个数字的时候需要特判. #include <cstdio> #include <cmath> #include <set> #include <cstring> #include <algorithm> using namespace std; int L,R; int main() { while(~scanf("%d%d",&am…
每日CF: 411div2 Solved A CodeForces 805A Fake NP Solved B CodeForces 805B 3-palindrome Solved C CodeForces 805C Find Amir Solved D CodeForces 805D Minimum number of steps Attempted E CodeForces 805E Ice cream coloring     F CodeForces 805F Expected dia…
B. Case of Fake Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/556/problem/B Description Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famou…
题目传送门 /* 题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1 构造:先求出使第1个指向0要多少步,按照这个次数之后的能否满足要求 题目读的好累:( */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath>…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, pu…
题目链接:http://codeforces.com/problemset/problem/556/B 题目意思:给出 n 个齿轮,每个齿轮有 n 个 teeth,逆时针排列,编号为0 ~ n-1.每按一次 button,每个齿轮都会有且仅有一个活动的tooth,对于偶数编号的齿轮,它下一个活动tooth是紧挨着当前tooth的逆时针方向的那个:而奇数编号的齿轮,下一个活动tooth是顺时针的那个.给出每个齿轮的活动tooth,问通过按下有限次的button,问能不能得到一个0,1,...,n-…
/////////////////////////////////////////////////////////////////////////////////////////////////////// 作者:stxy-ferryman声明:本文遵循以下协议自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0 查看本文更新与讨论请点击:http://www.cnblogs.com/stxy-ferryman/链接被删请百度:stxy-ferryman…