CodeForces 688A Opponents (水题)

题意:给定 n 行数,让你找出连续最多的全是1的个数。

析:好像也没什么可说的,那就判断一下,并不断更新最大值呗。

代码如下:

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <set>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>

using namespace std;
typedef long long LL;
string s;

int main(){
    int n, d, cnt = 0;
    bool ok = false;
    int m = -1;
    scanf("%d %d", &n, &d);
    for(int i = 0; i < d; ++i){
        cin >> s;
        int j;
        for(j = 0; j < n; ++j)
            if(s[j] != ‘1‘)  break;

        if(ok && j != n)  ++cnt;
        else if(j != n){  ok = true; cnt = 1; }
        else{ cnt = 0; ok = false; }
        m = max(m ,cnt);
    }
    printf("%d\n", m);
    return 0;
}
时间: 2024-08-24 05:42:56

CodeForces 688A Opponents (水题)的相关文章

CodeForces 20B Equation 水题

题目链接:点击打开链接 #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <iostream> #include <map> #include <set> #include <math.h> using namespace std; #define inf 10000000 #define l

CodeForces 705A Hulk (水题)

题意:输入一个 n,让你输出一行字符串. 析:很水题,只要判定奇偶性,输出就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring

CodeForces 474B Worms (水题,二分)

题意:给定 n 堆数,然后有 m 个话询问,问你在哪一堆里. 析:这个题是一个二分题,但是有一个函数,可以代替写二分,lower_bound. 代码如下: #include<bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 1e5 + 5; int a[maxn]; int main(){ int n, m; cin >> n; for(int i = 1; i <= n; +

codeforces 377A. Puzzles 水题

A. Puzzles Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/337/A Description The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to p

CodeForces 709A Juicer (水题, 模拟)

题意:给定 n 个桔子的大小,一个杯子的容积,一个最大限度,挨着挤桔子汁,如果大小大于限度,扔掉,如果不杯子满了倒掉,问你要倒掉多少杯. 析:直接按要求模拟就好,满了就清空杯子. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath&g

CodeForces 474A Keyboard (水题)

题意:给定一个键盘,然后一行字母,和一个字符,代表把那一行字母在键盘上左移还是右移一位. 析:没什么好说的,直接暴力就好. 代码如下: #include<bits/stdc++.h> using namespace std; typedef long long LL; char s1[] = "qwertyuiop"; char s2[] = "asdfghjkl;"; char s3[] = "zxcvbnm,./"; char s

CodeForces 513A Game (水题,博弈)

题意:两个人有n1,n2个球,然后分别最多拿出 k1,k2个球,然后扔掉,谁先拿完谁输. 析:很简单么,每人都足够聪明,就每次扔一个好了,那么,谁的球多,谁就能赢呗,如果相等,那么第一个扔的输. 代码如下: #include <iostream> #include <cstdio> using namespace std; int main(){ int n, m, k, l; cin >> n >> m >> k >> l; if(

CodeForces 616A(水题)

while(t--) 最后结果t=-1 #include <iostream> #include <string> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> #include <stack> using namespace std; #define MEM(a,b)

CodeForces 707B Bakery (水题,暴力,贪心)

题意:给定n个城市,其中有k个有仓库,问你在其他n-k个城市离仓库的最短距离是多少. 析:很容易想到暴力,并且要想最短,那么肯定是某一个仓库和某一个城市直接相连,这才是最优,所以只要枚举仓库,找第一个城市,然后更新答案即可. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib&g