codeforces 688A A. Opponents(水题)
题目链接:
1 second
256 megabytes
standard input
standard output
Arya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day at least one of Arya's opponents is absent at the school, then Arya will beat all present opponents. Otherwise, if all opponents are present, then they will beat Arya.
For each opponent Arya knows his schedule — whether or not he is going to present on each particular day. Tell him the maximum number of consecutive days that he will beat all present opponents.
Note, that if some day there are no opponents present, Arya still considers he beats all the present opponents.
The first line of the input contains two integers n and d (1 ≤ n, d ≤ 100) — the number of opponents and the number of days, respectively.
The i-th of the following d lines contains a string of length n consisting of characters '0' and '1'. The j-th character of this string is '0' if the j-th opponent is going to be absent on the i-th day.
Print the only integer — the maximum number of consecutive days that Arya will beat all present opponents.
2 2
10
00
2
4 1
0100
1
4 5
1101
1111
0110
1011
1111
2 题意: 全是1的时候就是失败的时候,找最长的0的序列;
思路:
水题
AC代码:
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio> using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<''||CH>'';F= CH=='-',CH=getchar());
for(num=;CH>=''&&CH<='';num=num*+CH-'',CH=getchar());
F && (num=-num);
}
int stk[], tp;
template<class T> inline void print(T p) {
if(!p) { puts(""); return; }
while(p) stk[++ tp] = p%, p/=;
while(tp) putchar(stk[tp--] + '');
putchar('\n');
} const LL mod=1e9+;
const double PI=acos(-1.0);
const LL inf=1e18;
const int N=1e4+;
const int maxn=;
const double eps=1e-; char str[][];
int a[];
int main()
{ int n,d;
read(n);read(d);
for(int i=;i<=d;i++)
{
scanf("%s",str[i]);
int flag=;
for(int j=;j<n;j++)
{
if(str[i][j]=='')flag=;
}
if(flag)a[i]=;
}
int ans=,len=;
for(int i=;i<=d;i++)
{
if(a[i])
{
len++;
}
else
{
ans=max(ans,len);
len=;
}
}
ans=max(ans,len);
cout<<ans<<"\n"; return ;
}
codeforces 688A A. Opponents(水题)的更多相关文章
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- Codeforces Gym 100531G Grave 水题
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...
- codeforces 706A A. Beru-taxi(水题)
题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...
- codeforces 569B B. Inventory(水题)
题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces 489A SwapSort (水题)
A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- CodeForces 534B Covered Path (水题)
题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...
- Codeforces Gym 100286I iSharp 水题
Problem I. iSharpTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- CodeForces 705A(训练水题)
题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it ...
- CodeForces Gym 100685C Cinderella (水题)
题意:给定 n 个杯子,里面有不同体积的水,然后问你要把所有的杯子的水的体积都一样,至少要倒少多少个杯子. 析:既然最后都一样,那么先求平均数然后再数一下,哪个杯子的开始的体积就大于平均数,这是一定要 ...
随机推荐
- XV6调度
调度 任何操作系统都可能碰到进程数多于处理器数的情况,这样就需要考虑如何分享处理器资源.理想的做法是让分享机制对进程透明.通常我们对进程造成一个自己独占处理器的假象,然后让操作系统的多路复用机制(mu ...
- hdu 1232水
#include<stdio.h> #define N 1000 int pre[N]; int find(int n ){ return pre[n]=n==pre[n]?n:find( ...
- JS中的call()和apply()方法区别
如 果没接触过动态语言,以编译型语言的思维方式去理解javaScript将会有种神奇而怪异的感觉,因为意识上往往不可能的事偏偏就发生了,甚至觉得不可 理喻.如果在学JavaScript这自由而变幻无穷 ...
- hdu 5187 zhx's contest [ 找规律 + 快速幂 + 快速乘法 || Java ]
传送门 zhx's contest Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- Codeforces Round #533 (Div. 2) E 最大独立集
知识点 最大独立集(set) = 补图的最大团(clique ) 最小顶点覆盖 + 最大独立集 = V E. Helping Hiasat time limit per test 2 seconds ...
- C# 通过T4自动生成代码
通过T4模板生成代码,运行时实现 关键代码段:Host using Microsoft.VisualStudio.TextTemplating; using System; using System. ...
- 包装类Float中为什么有两个常量来表示最小值
1)问:包装类Float中为什么有两个常量来表示最小值:MIN_VALUE和MIN_NORMAL ① MIN_VALUE:最小正非零值常量,是非规格化浮点数所能表示的最小值.值为 3.4E-45 的常 ...
- 转 linux socket的select函数例子
使用select函数可以以非阻塞的方式和多个socket通信.程序只是演示select函数的使用,功能非常简单,即使某个连接关闭以后也不会修改当前连接数,连接数达到最大值后会终止程序. 1. 程序使用 ...
- 【stl学习笔记】set、multiset
set和multiset会根据特定的排序准则,自动将元素排序.两者不同处在于multiset允许元素重复而set不允许 在使用set或multiset之前,必须先加入头文件<set> se ...
- 用CSS画小猪佩奇,你就是下一个社会人! js将“I am a coder”反转成 “coder a am I”,不许用split,join,subString,reverse;求解方法三
用CSS画小猪佩奇,你就是下一个社会人! 欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 作者:江志耿 | 腾讯TEG网络工程师 我是佩奇,哼,这是我的弟弟乔治,呱呱,这是我的妈妈,嚯 ...