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 ;
}
最新文章
- HTML两张图片叠加问题的进一步修改
- ZOJ 1015 Fishing Net(弦图判定)
- IE9 JSON未定义
- 重绘panel控件,实现panel的阴影效果
- 谁会是 Zabbix 和 Nagios 的继任者?
- automake使用
- Redis的Time Event与File Event的微妙关系
- ZOJ 3795 Grouping
- ERROR 1114 (HY000): The table &#39;adv_date_tmp&#39; is full(Mysql临时表应用)
- 再回首,Java温故知新(十一):Java反射
- JavaScript高级程序设计(学习笔记)
- 【bzoj4571&;&;SCOI2016美味】
- QPropertyAnimation实现图形,控件的旋转和位移动画,尤其是旋转
- 通过Weeman+Ettercap配合拿下路由器管理权限
- mac 全角/半角标点符号切换
- C语言 &#183; 8皇后问题
- 查看CPU核数和内存
- Linux进程共享通信 -- mmap实现
- JSP之静态include指令、动态Include指令
- Python之路----列表推导式和生成器的表达式
热门文章
- 【Kubernetes】Kubernetes的Service外部访问方式:NodePort和LoadBalancer
- 什么是Service Mesh?
- Django 的信号 &; Flask 的信号
- BZOJ1740: [Usaco2005 mar]Yogurt factory 奶酪工厂
- BZOJ1700: [Usaco2007 Jan]Problem Solving 解题
- SUSE linux使用zypper 安装软件-比yum更好用
- UITextInputMode currentInputMode is deprecated. 警告的解决
- SQL SERVER 2012 第五章 创建和修改数据表 の CREATE语句
- zookeeper一二三
- 【Nginx】定时器事件