题目链接: http://codeforces.com/problemset/problem/691/A 题目大意: n个数0或1,要求恰好n-1个1,如果n为1则那个数一定要是1 题目思路: [模拟] 水题一道.看错题目两次.. // //by coolxxx //#include<bits/stdc++.h> #include<iostream> #include<algorithm> #include<string> #include<ioman…
水题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<algorithm> #include<vector> #include<map> #include<set> #in…
题目链接: A. Fashion in Berland 题意: 思路: AC代码: //#include <bits/stdc++.h> #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; #define For(i,j,n) for(int i=j;i&l…
A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if…
codeforces 808G Anthem of Berland 题面 给定\(s\)串和\(t\)串,字符集是小写字母.\(s\)串中有些位置的值不确定,要求你确定这些位置上的值,使得\(t\)在\(s\)中出现次数最多,输出最多出现次数. 参考博客 http://www.cnblogs.com/Oncle-Ha/p/7061929.html 题解 AC自动机预处理 \(ne[i][j]\):字符串 \(t[i]+j\) 的后缀最长匹配到 \(t[ne[i][j]]\). 状态\(f[i][…
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, 然后接下来的t秒需要的蜡烛都燃烧着,超过t秒,每减少一秒灭一支蜡烛,好!!! 详细解释:http://blog.csdn.net/kalilili/article/details/43412385 */ #include <cstdio> #include <algorithm> #i…
题目地址:http://codeforces.com/problemset/problem/350/C /* 题意:机器人上下左右走路,把其他的机器人都干掉要几步,好吧我其实没读懂题目, 看着样例猜出来的,这题也蛮水的 模拟+贪心:sort一下,从最近的开始走 注意:坐标有一个为0的比普通的少一半的步骤,每次干掉一个要返回原来的位置 */ #include <cstdio> #include <iostream> #include <algorithm> #includ…
题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单,依据公式得知折线一定是一上一下的,只要把两个相邻的坐标之间的折线填充就好 注意:坐标有可能为负数,所以移动值y初始化为1000,最后要倒过来输出 详细解释:http://blog.csdn.net/zhb1997/article/details/27877783 */ #include <cstd…
B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hierog…
题目传送门 /* 模拟:这就是一道模拟水题,看到标签是贪心,还以为错了呢 题目倒是很长:) */ #include <cstdio> #include <algorithm> #include <iostream> #include <algorithm> #include <cstring> using namespace std; ; const int INF = 0x3f3f3f3f; ]; char s[MAXN]; int main(…
题目传送门 /* 题意:两堆牌,每次拿出上面的牌做比较,大的一方收走两张牌,直到一方没有牌 queue容器:模拟上述过程,当次数达到最大值时判断为-1 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <stack> #include <cmath> #inc…
题目传送门 /* 模拟水题:给定n*m的空白方格,k次涂色,将(x,y)处的涂成黑色,判断第几次能形成2*2的黑色方格,若不能,输出0 很挫的判断四个方向是否OK */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include <map> using namespace std; ; c…
A. Parliament of Berland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamen…
题目传送门 传送点I 传送点II 传送点III 题目大意 给定一个字符串$s$,和一个字符串$t$,$t$只包含小写字母,$s$包含小写字母和通配符'?'.询问$t$可能在$s$中出现最多多少次. 原来觉得挺神仙,现在觉得还好. 显然用$g_{i}$表示在匹配到第$i$个字符,最多能匹配$t$的次数. 现在讨论它的转移,需要考虑它和前一个匹配有没有重叠. 如果没有重叠,直接从$g_{i - |t|}$转移. 如果有重叠,上一个可能的匹配的结束位置显然是可以枚举的,通过跳$fail$就能找到.我们…
C. Ancient Berland Circus time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.…
Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary fro…
Circle of Students time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are nn students standing in a circle in some order. The index of the ii-th student is pipi. It is guaranteed that a…
Problem's Link:http://codeforces.com/problemset/problem/475/Chttp://codeforces.com/problemset/problem/475/C Mean: 给你一个网格,每个格子中是'X'或'.',你需要用一个刷子去将这些'X'刷掉,而且不能刷到'.',每次只能往下走或者往右走,让你选一把最小的刷子出来. analyse: 爆搜+模拟. 1)我们先遍历两遍,求出最小连续的x和y,那么x和y就是刷子最大能够达到的大小: 2)对…
题意 给定一个字符串 \(s\) ,一个字符串 \(t\) ,其中 \(s\) 包含小写字母和 "?" ,\(t\) 只包含小写字母,现在把 \(s\) 中的问号替换成任意的小写字母,求 \(t\) 最多在 \(s\) 中出现多少次,\(t\) 可以互相覆盖. \(1 \leq |s| \leq 10^5\) \(1 \leq |t| \leq 10^5\) \(1 \leq |s|\cdot|t| \leq 10^7\) 思路 由于 \(|s|\cdot|t| \leq 10^7\)…
LINK 简要题意 给你一个串s,上面有字母和一些通配符,问你将通配符换成字母之后最多可以出现多少次串t 首先有一个很傻子的做法就是\(dp_{i,j}\)表示s到第i个位置匹配t串前j个字符的完整t串个数 然后每次枚举前缀看看能不能转移...太不优秀了 那么就考虑这样做: \(dp_{i}\)表示最后一个出现的完整的串t在第i个位置结尾的最大出现次数 \(maxv_{i}\)表示最后一个出现的完整的串t在第i个位置前结尾的最大出现次数 首先有一个转移是,如果当前位置被匹配,那么\(dp_{i}…
题意:给定一个n*m的矩阵,*表示陆地, . 表示水,一些连通的水且不在边界表示湖,让你填最少的陆地使得图中湖剩下恰好为k. 析:很简单的一个搜索题,搜两次,第一次把每个湖的位置和连通块的数量记下来,第二次去填陆地,选少的进行填. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdli…
解题思路: 1.dfs所有的水,顺便计数大小并判断是不是湖. 2.如果是湖,将大小和坐标存下来. 3.对湖按大小从小到大排序. 4.dfs前(湖的数量-k)个湖,用*填充这些湖. 代码: #include <bits/stdc++.h> using namespace std; typedef long long ll; struct lake{ int x;int y; int size; bool islake; }; vector <lake> l; ][]; ][]; in…
 题意是需要求最大的扩散时间,最后输出的是一开始的火源点,那么我们比较容易想到的是二分找最大值,但是我们在这满足这样的点的时候可以发现,在当前扩散时间k下,以这个点为中心的(2k+1)2的正方形块内必须全部都是'X'才行,那么要访问这样的块内的'X'个数显然需要使用二维前缀和维护一下就可以O(1)求出个数,那么这部分问题我们解决,接下来就是二分的如何Check,那么既然我们之前找到了这样满足当期扩散时间的点后,我们只需要直接将这块矩形内部的点全部打标记,显然我们可以得知,如果当前扩散时间是满足要…
Tokitsukaze and Discard Items time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Recently, Tokitsukaze found an interesting game. Tokitsukaze had nn items at the beginning of this game. Howeve…
A - Fashion in Berland 水 // #pragma comment(linker, "/STACK:102c000000,102c000000") #include <iostream> #include <cstdio> #include <cstring> #include <sstream> #include <string> #include <algorithm> #include &…
Spit Problem CodeForces - 29A In a Berland's zoo there is an enclosure with camels. It is known that camels like to spit. Bob watched these interesting animals for the whole day and registered in his notepad where each animal spitted. Now he wants to…
Qualifying Contest CodeForces - 659B Very soon Berland will hold a School Team Programming Olympiad. From each of the mBerland regions a team of two people is invited to participate in the olympiad. The qualifying contest to form teams was held and i…
Ancient Berland Circus CodeForces - 1C 如今,Berland 的所有马戏表演都有一个圆形的竞技场,其直径为 13 米,但过去的情况有所不同. 在古代 Berland,马戏表演的竞技场的形状为 (等角) 正多边形,其尺寸和角的度数在各马戏表演中可能各不相同.在竞技场的每个角上,有一根特殊的台柱,并且在不同台柱之间系上绳子用以标识竞技场的各条边. 最近,来自 Berland 的科学家们已经发现了某处古代马戏表演竞技场的遗址.他们只发现了三根台柱,其余的则随时间而…
UVa 1625 color length https://blog.csdn.net/Dylan_Frank/article/details/52261424 https://www.cnblogs.com/jerryRey/p/4740944.html Uva-1375 The Best Name for Your Baby(未解决) https://blog.csdn.net/u014258433/article/details/69070747 CodeForces - 17C Bala…
B. Berland National LibraryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/B Description Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any o…