text
stringlengths
49
983k
#include <bits/stdc++.h> int main() { long long int n, m, a, cou = 0, count = 0, i; scanf("%lld %lld", &n, &m); char str[n + 5]; while (m--) { scanf("%s", str); a = 0; for (i = 0; i < n; i++) { if (str[i] == '0') { a++; break; } } if (a == 1) { count++; } else if (a == 0) { if (count >= cou) cou = count; count = 0; } } if (count > cou) cou = count; printf("%lld\n", cou); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s[105]; int n, m, f = 0, t = 0; cin >> n >> m; for (int i = 0; i < m; i++) cin >> s[i]; for (int i = 0; i < m; i++) { if (s[i].find('0') != -1) { f++; t = max(t, f); } else f = 0; } cout << t << endl; return 0; }
#include <bits/stdc++.h> const int maxn = 100; using namespace std; int n, d; int ans, temp; string a; int flag[maxn + 10]; int main() { cin >> n >> d; for (int i = 1; i <= d; i++) { cin >> a; if (a.find("0") != a.npos) { flag[i] = 1; } } for (int i = 1; i <= d; i++) { if (flag[i]) { temp++; } else { ans = max(ans, temp); temp = 0; } } ans = max(ans, temp); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, m, ans = 0, count = 0; cin >> n >> m; string s; while (m--) { cin >> s; bool f = false; for (long long int i = 0; i < n; i++) { if (s[i] == '0') { f = true; break; } } if (f) { count++; ans = max(ans, count); } else count = 0; } cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int n, d, a[200], ans, cur; int main() { cin >> n >> d; for (int i = 1; i <= d; ++i) { string s; cin >> s; a[i] = 0; for (int j = 0; j < s.size(); ++j) if (s[j] == '0') { a[i] = 1; break; } } for (int i = 1; i <= d; ++i) { if (a[i]) { cur++; ans = max(ans, cur); } else cur = 0; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int i, n, d, cont = 0, maior_cont = 0; string s; cin >> n >> d; while (d--) { cin >> s; int temp = cont; for (i = 0; i < n; i++) { if (s[i] != '1') { cont++; break; } } if (cont > maior_cont) maior_cont = cont; if (temp == cont) cont = 0; } cout << maior_cont << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char str[105]; int n, d; while (~scanf("%d%d", &n, &d)) { int sum = 0, flag = 0; int maxn = 0; for (int i = 0; i < d; i++) { scanf("%s", str); for (int i = 0; i < strlen(str); i++) { if (str[i] == '0') { flag = 1; break; } } if (flag) sum++; else sum = 0; maxn = max(sum, maxn); flag = 0; } printf("%d\n", maxn); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long c = 0, cn = 0, cnt = 0; long long n, d; cin >> n >> d; string s; for (int i = 0; i < d; i++) { cin >> s; int l = s.find('0'); if (l >= 0) { c++; if (c > cnt) { cnt = c; } } else c = 0; } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); long long n, d; cin >> n >> d; string s; long long l = 0, ans = 0; while (d--) { cin >> s; bool beat = false; for (char ch : s) if (ch == '0') beat = true; if (beat) l++; else l = 0; ans = max(ans, l); } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int check(char *ch) { for (int i = 0; *(ch + i); i++) { if (*(ch + i) == '0') return 1; } return 0; } int main() { int n, day, counter = 0; char str[105]; ios::sync_with_stdio(0); cin.tie(0); cin >> n >> day; int consecutive[day], j = 0; for (int i = 0; i < day; i++) consecutive[i] = 0; cin.ignore(); for (int i = 1; i <= day; i++) { cin >> str; int ans = check(&str[0]); if (ans == 0) j++; else consecutive[j]++; } sort(consecutive + 0, consecutive + day); cout << consecutive[day - 1]; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, p, m; string s; int a[10000]; cin >> n >> d; p = 0; int q = d; int c = 0; int flag; while (d--) { flag = 0; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == '0') { flag = 1; } } if (flag == 1) { c++; a[p++] = c; } else { a[p++] = c; c = 0; } } sort(a, a + p); cout << a[p - 1] << endl; }
#include <bits/stdc++.h> using namespace std; std::vector<string> v; std::vector<int> win; int main() { int n, d; cin >> n >> d; int count = 0, ans = 0; for (int i = 0; i < d; i++) { string s; cin >> s; int flag = 0; for (int i = 0; i < n; i++) { if (s[i] == '0') { flag = 1; } } if (flag) { count++; } else { count = 0; } ans = max(ans, count); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; template <class T> inline void Qmin(T &a, const T b) { if (b < a) a = b; } template <class T> inline void Qmax(T &a, const T b) { if (a < b) a = b; } inline int Qceil(int x, int y) { return (x - 1) / y + 1; } int X_D[9] = {0, -1, -1, -1, 0, 1, 1, 1}; int Y_D[9] = {-1, -1, 0, 1, 1, 1, 0, -1}; int bin_0_9[] = {0, 1, 1, 2, 1, 1, 2, 3, 1, 1}; int month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char chr[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; string day_0_7[] = {"Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"}; int power_of_2s[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912}; string ans[13][32]; int prime[1000001]; int min(int x, int y) { return x < y ? x : y; } int max(int x, int y) { return x > y ? x : y; } int main() { int n, d; string s; cin >> n >> d; int i, j; int ans = 0, temp = 0; for (i = 1; i <= d; i++) { cin >> s; int flg = 0; for (j = 0; j < n; j++) { if (s[j] == '0') { flg = 1; break; } } if (flg) { temp++; } else temp = 0; if (temp > ans) ans = temp; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int n, d; int main() { scanf("%d%d", &n, &d); getchar(); int ans = 0, flag; int mx = 0; for (int i = 1; i <= d; i++) { flag = 0; for (int j = 1; j <= n; j++) { int tmp = getchar() - '0'; if (!tmp && !flag) { ans++; flag = 1; mx = max(mx, ans); } } getchar(); if (!flag && i != d) { ans = 0; } } mx = max(mx, ans); printf("%d\n", mx); return 0; }
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > a[100005]; int main() { int n, m, k = 0, c = 0, l = -1; string x; cin >> n >> m; while (m--) { cin >> x; l = x.find('0'); if (l != -1) { k++; c = max(c, k); } else { k = 0; } } c = max(c, k); cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; const int MAX_NUMBER = 100 + 10; bool winDays[MAX_NUMBER]; int main() { int oponentsNumber, daysNumber; cin >> oponentsNumber >> daysNumber; for (int i = 0; i < daysNumber; i++) { string appearance; cin >> appearance; bool areAllPresent = true; for (int j = 0; j < appearance.size(); j++) { if (appearance[j] == '0') { areAllPresent = false; } } if (areAllPresent) winDays[i] = false; else winDays[i] = true; } int consequetiveWins = 0; int mostConsequetiveWins = 0; for (int i = 0; i < daysNumber; i++) { if (winDays[i]) { consequetiveWins++; } else { if (consequetiveWins > mostConsequetiveWins) { mostConsequetiveWins = consequetiveWins; } consequetiveWins = 0; } } if (consequetiveWins > mostConsequetiveWins) cout << consequetiveWins; else cout << mostConsequetiveWins; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; char aa[d][n]; int a[d + 1]; memset(a, 0, sizeof(a)); for (int i = 0; i < d; i++) { for (int j = 0; j < n; j++) { cin >> aa[i][j]; if (aa[i][j] == '0') a[i] = 1; } } int countt = 0; int maxx = 0; for (int i = 0; i < d; i++) { if (a[i] == 1) { countt++; if (a[i + 1] == 0) { if (maxx <= countt) { maxx = countt; } countt = 0; } } } cout << maxx; return 0; }
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b) { long long res = 1; while (b) { if (b % 2 == 1) res = (res * a) % 1000000007; a = (a * a) % 1000000007; b /= 2; } return res % 1000000007; } long long power(long long a, long long b, long long mod) { if (b == 0) return 1; if (b == 1) return (a % mod); else { if (b % 2 == 0) { long long temp = power(a, b / 2, mod); return (temp * temp) % mod; } else { long long temp = power(a, b / 2, mod); temp = (temp * temp) % mod; return (temp * a) % mod; } } } long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); } long long moduloinverse(long long a, long long mod) { return power(a, mod - 2, mod); } long long min(long long a, long long b) { return a > b ? b : a; } long long max(long long a, long long b) { return a > b ? a : b; } long long binarysearch(long long *a, long long n, long long k) { long long low = 0, high = n - 1, mid; while (low <= high) { mid = low + (high - low) / 2; if (a[mid] < k) { low = mid + 1; } else if (a[mid] > k) { high = mid - 1; } else { return mid; } } return -1; } int main() { int n, d, l, f, ans = 0, mx = -1; cin >> n >> d; string s; for (int i = 0; i < d; i++) { cin >> s; f = 0; l = s.length(); for (int j = 0; j < l; j++) { if (s[j] == '1') f++; } if (f != l) ans++; else ans = 0; if (ans > mx) { mx = ans; } } cout << mx << endl; return 0; }
#include <bits/stdc++.h> using namespace std; char word[110]; void solve() { int n, d; cin >> n >> d; int ans = 0; int loc = 0; for (int i = 0; i < d; ++i) { bool win = false; cin >> word; for (int i = 0; i < n; ++i) if (word[i] == '0') { win = true; break; } if (win) { if (++loc > ans) ans = loc; } else loc = 0; } cout << ans << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int d = 49 * n; int c = 0, arn = 0, maxi = 0; for (int i = 0; i < m; i++) { string s; cin >> s; int k = 0; for (int j = 0; j < n; j++) { k += (int)s[j]; } if (k < d) { arn++; } else { arn = 0; } maxi = max(maxi, arn); } cout << maxi; return 0; }
#include <bits/stdc++.h> using namespace std; long long day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; long long dx[] = {0, 1, 0, -1}; long long dy[] = {1, 0, -1, 0}; struct edge { long long to, cost; }; bool isupper(char c) { if ('A' <= c && c <= 'Z') return 1; return 0; } bool islower(char c) { if ('a' <= c && c <= 'z') return 1; return 0; } bool isPrime(long long x) { if (x == 1) return 0; if (x == 2) return 1; if (x % 2 == 0) return 0; for (long long i = 3; i * i <= x; i++) if (x % i == 0) return 0; return 1; } bool iskaibun(string s) { for (long long i = 0; i < s.size() / 2; i++) if (s[i] != s[s.size() - i - 1]) return 0; return 1; } bool isnumber(char c) { return ('0' <= c && c <= '9'); } bool isalpha(char c) { return (isupper(c) || islower(c)); } void printvi(vector<long long> v) { for (long long i = (long long)0; i < (long long)v.size(); i++) { if (i) cout << " "; cout << v[i]; } cout << endl; } void printvil(vector<long long> v) { for (long long i = (long long)0; i < (long long)v.size(); i++) { cout << v[i] << endl; } } void printvvi(vector<vector<long long>> v) { for (long long i = (long long)0; i < (long long)v.size(); i++) { for (long long j = (long long)0; j < (long long)v[i].size(); j++) { if (j) cout << " "; cout << v[i][j]; } cout << endl; } } void printvstr(vector<string> v) { for (long long i = (long long)0; i < (long long)v.size(); i++) { cout << v[i] << endl; } } long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } struct S { long long idx, value; }; signed main() { long long w, h; cin >> w >> h; long long ans = 0; auto all1 = [&](string s) { for (long long i = (long long)0; i < (long long)s.size(); i++) if (s[i] == '0') { return false; } return true; }; vector<long long> v(h); for (long long i = (long long)0; i < (long long)h; i++) { string s; cin >> s; v[i] = all1(s); } for (long long i = (long long)0; i < (long long)h; i++) { if (v[i] == 0) { long long subans = 1; while (i + 1 < h and v[i] == v[i + 1]) { i++; subans++; } ans = max(ans, subans); } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, ans = 0, cnt = 0, g; cin >> n >> d; for (int i = 0; i < d; i++) { string a; cin >> a; g = cnt; for (int j = 0; j < n; j++) { if (a[j] == '0') { cnt++; break; } } if (g == cnt) { ans = max(ans, cnt); cnt = 0; } } cout << max(ans, cnt); }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; scanf("%d", &n); scanf("%d", &d); map<int, bool> flag; for (int i = 1; i <= d; i++) { string s; cin >> s; for (int j = 0; j < s.size(); j++) { if (s[j] == '0') flag[i] = true; } } int ans = 0, res = 0, prev = 0; for (int i = 1; i <= d; i++) { res = max(res, ans); if (!flag[i]) ans = 0; else ans++; } res = max(res, ans); cout << res; printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; string arr[104]; bool flag[104]; int main() { int n, d; cin >> n >> d; for (int i = 1; i <= d; i++) { cin >> arr[i]; } for (int i = 1; i <= d; i++) { bool yes = false; for (int j = 0; j < n; j++) { if (arr[i][j] == '0') { yes = true; break; } } if (yes) { flag[i] = true; } } int maxx = 0, cnt = 0; for (int i = 1; i <= d; i++) { if (flag[i] == true) { cnt++; } else { maxx = max(maxx, cnt); cnt = 0; } } printf("%d\n", max(maxx, cnt)); }
#include <bits/stdc++.h> using namespace std; long long n, ans, d, mx; string s, st; int main() { cin >> n >> d; for (int i = 1; i <= n; i++) s += '1'; for (int i = 1; i <= d; i++) { cin >> st; if (st != s) ans++; else ans = 0; mx = max(ans, mx); } cout << mx; }
#include <bits/stdc++.h> using namespace std; char s[101]; bool f[101]; int main() { int n, d, ans = 0, cnt = 0; scanf("%d%d", &n, &d); for (int i = 1; i <= d; i++) { scanf("%s", s + 1); for (int j = 1; j <= n; j++) if (s[j] == '0') f[i] = 1; } for (int i = 1; i <= d; i++) if (!f[i]) { ans = max(ans, cnt); cnt = 0; } else cnt++; ans = max(ans, cnt); printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; vector<string> v(d); for (int i = 0; i < d; ++i) { cin >> v[i]; } int maxdays = 0, cur = 0; for (int i = 0; i < d; ++i) { bool beat = false; for (int j = 0; !beat && j < n; ++j) { if (v[i][j] == '0') beat = true; } if (beat) { ++cur; maxdays = (cur > maxdays ? cur : maxdays); } else { cur = 0; } } cout << maxdays << endl; }
#include <bits/stdc++.h> using namespace std; int n, d, x[105], tmp, ans, last; int main() { scanf("%i %i", &n, &d); last = 1; for (int i = 1; i <= d; i++) { x[i] = 1; for (int j = 0; j < n; j++) { scanf("%1d", &tmp); x[i] *= tmp; } if (x[i]) { ans = max(i - last, ans); last = i + 1; } } ans = max(ans, d + 1 - last); printf("%i\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; vector<int> divisors[500007 + 1]; void divisors_1_to_n(int n) { for (int i = 1; i <= n; i++) { for (int j = i; j <= n; j += i) divisors[j].push_back(i); } } int main() { ios_base::sync_with_stdio(0); divisors_1_to_n(500007 + 1); int i, n, d, mx = 0, cmx = 0; cin >> n >> d; string s; for (i = 0; i < d; i++) { cin >> s; int c = 0; for (int j = 0; j < s.size(); j++) { if (s[j] == '1') c++; } if (s.size() != c) cmx++; else { if (mx < cmx) mx = cmx; cmx = 0; } } if (mx < cmx) mx = cmx; cout << mx << endl; ; }
#include <bits/stdc++.h> using namespace std; int arr[105][105]; int win[105]; int main() { int n, d; string s; scanf("%d %d", &n, &d); ; memset(win, 0, sizeof(win)); memset(arr, 0, sizeof(arr)); for (int x = 1; x <= d; x++) { cin >> s; for (int i = 0; i <= n - 1; i++) { if (s[i] == '1') { arr[x][i + 1] = 1; } } } for (int day = 1; day <= d; day++) { int cnt = 0; for (int op = 1; op <= n; op++) { if (arr[day][op] == 1) cnt++; } if (cnt < n) win[day] = 1; } int mxD = 0; int cD = 0; for (int x = 1; x <= d; x++) { if (win[x] == 0) { mxD = max(mxD, cD); cD = 0; } else { cD++; } } mxD = max(cD, mxD); cout << mxD << endl; return 0; }
#include <bits/stdc++.h> int main() { int max, a, cnt = 0, n, d, i, j, c = 0, t = 0; scanf("%d %d", &n, &d); char x[n]; int ara[150] = {0}; for (i = 0; i < d; i++) { scanf("%s", &x); for (j = 0; j < n; j++) { c = c + x[j] - '0'; } if (c == n) { cnt++; } else ara[cnt]++; c = 0; } max = ara[0]; for (i = 1; i <= cnt; i++) { if (ara[i] > max) max = ara[i]; } printf("%d\n", max); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, i, p = 0, m = 0; cin >> n >> d; char a[111], l[111]; for (i = 0; i < n; i++) { l[i] = '1'; } l[n] = '\0'; while (d--) { cin >> a; a[n] = '\0'; if (!!strcmp(a, l)) { p++; } else { if (m < p) m = p; p = 0; } } if (m < p) m = p; cout << m; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, maxStreak = 0, currentStreak = 0; string h, p; cin >> n >> d; p.assign(n, '1'); for (int i = 0; i < d; i++) { cin >> h; if (h.compare(p) == 0) currentStreak = 0; else currentStreak++; maxStreak = max(maxStreak, currentStreak); } cout << maxStreak << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool Beat(string s) { for (int i = 0; i < s.size(); ++i) if (s[i] == '0') return true; return false; } int main() { int n, d, c = 0, Max = 0; cin >> n >> d; string s; bool cont = false; for (int i = 0; i < d; ++i) { cin >> s; if (Beat(s)) { cont = true; } else cont = false; if (cont) { c++; Max = max(Max, c); } else { c = 0; } } cout << Max; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; int c_days = 0, ans = 0; while (d--) { string s; bool cons = false; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') { c_days++; ans = max(c_days, ans); cons = true; break; } } if (!cons) { c_days = 0; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, mx = 0, days = 0; cin >> n >> d; for (int i = 0; i < d; i++) { string s; cin >> s; int win = 0; for (int j = 0; j < n; j++) { if (s[j] == '0') { win = 1; break; } } if (win) days++; else days = 0; mx = max(mx, days); } cout << mx; }
#include <bits/stdc++.h> int main() { char a[105]; int n, m, flag = 0, maxx = 0, s = 0; scanf("%d %d", &n, &m); for (int i = 0; i < m; i++) { scanf("%s", a); int t = strlen(a); for (int j = 0; j < t; j++) { if (a[j] == '0') { flag = 1; break; } } if (flag == 1) { s++; flag = 0; } else { if (maxx < s) { maxx = s; } s = 0; } } if (maxx < s) { maxx = s; s = 0; } printf("%d\n", maxx); }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; string s; int ans = 0, cnt = 0; bool bo = false; for (int i = 0; i < d; i++) { cin >> s; for (int j = 0; j < n; j++) { if (s[j] == '0') bo = true; } if (!bo) { if (cnt > ans) ans = cnt; cnt = 0; } else cnt++; bo = false; } cout << max(ans, cnt); }
#include <bits/stdc++.h> using namespace std; int num[101]; int main() { int n, d, i, j, cnt = 0, mx = 0, m; cin >> n >> d; char ch[n]; for (i = 0; i < d; i++) { cin >> ch; for (j = 0; j < n; j++) { if (ch[j] == '0') { cnt++; mx = max(mx, cnt); break; } } if (j == n) { cnt = 0; } } cout << mx; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j, mx = 0, kol = 0; cin >> m >> n; for (i = 1; i <= n; i++) { int f = 0; for (j = 1; j <= m; j++) { char x; cin >> x; if (x == '0') f = 1; } if (f == 1) ++kol; else kol = 0; mx = max(kol, mx); } cout << mx << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, m, i, terbesar, j, skrng; bool menang; string s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; terbesar = 0; for (i = 0; i < m; i++) { cin >> s; menang = false; for (j = 0; j < s.length(); j++) { if (s[j] == '0') { menang = true; break; } } if (menang) { skrng++; if (skrng > terbesar) { terbesar = skrng; } } else { skrng = 0; } } cout << terbesar << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; scanf("%d %d", &n, &d); string s; int ans = 0, cnt = 0; bool flag; for (int i = 0; i < d; i++) { cin >> s; flag = false; for (int j = 0; j < n; j++) { if (s[j] == '0') { flag = true; break; } } if (flag) { cnt += 1; ans = max(ans, cnt); } else { cnt = 0; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int inf_int = 2e9; const long long inf_ll = 2e18; char s[105]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, d; scanf("%d%d", &n, &d); int num = 0; int maxn = 0, j; for (int i = 0; i < d; i++) { scanf("%s", s); for (j = 0; j < n; j++) { if (s[j] == '0') { num++; break; } } if (s[j - 1] == '1' && j == n) { maxn = max(maxn, num); num = 0; } } maxn = max(maxn, num); cout << maxn << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, d; string s; int best = 0, cnt = 0; int main() { cin >> n >> d; while (d--) { cin >> s; if (s.find('0') != string::npos) cnt++; else cnt = 0; best = max(best, cnt); } cout << best << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, count = 0, b = 0, t = 0; cin >> n >> m; string s; for (int i = 1; i <= m; i++) { cin >> s; for (int j = 0; j <= n - 1; j++) { if (s[j] == '1') { count++; } } if (count < n) { b++; } else { b = 0; } t = max(b, t); count = 0; } cout << t; }
#include <bits/stdc++.h> using namespace std; char s[105][105]; int main() { int n, d; scanf("%d", &n); ; scanf("%d", &d); ; for (int i = 0; i < d; i++) { scanf("%s", s[i]); ; } int ans = 0; int c = 0; for (int i = 0; i < d; i++) { int flag = 0; for (int j = 0; j < n; j++) { if (s[i][j] == '0') { flag = 1; } } if (flag) { c++; } else { c = 0; } ans = max(ans, c); } printf("%d\n", ans); ; }
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; char a[110]; int main() { int n, d; int num = 0, sum = 0, m = -1; cin >> n >> d; for (int i = 0; i < d; i++) { num = 0; cin >> a; for (int j = 0; j < n; j++) { if (a[j] == '0') num++; } if (num) sum++; else sum = 0; m = max(m, sum); } cout << m << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, d; cin >> n >> d; string s; int cnt, last = 0; int ans = 0; for (int i = 0; i < d; i++) { cin >> s; cnt = 0; for (int j = 0; j < n; j++) cnt += (s[j] - '0'); if (cnt == n) { ans = max(ans, i - last); last = i + 1; } } ans = max(ans, d - last); cout << ans; return 0; }
#include <bits/stdc++.h> int main() { int n, d, i, c = 0, m = 0, j, k = 0; char s[1000][1000]; scanf("%d %d", &n, &d); for (i = 0; i < d; i++) { scanf("%s", s[i]); } for (i = 0; i < d; i++) { m = 0; for (j = 0; j < n; j++) { if (s[i][j] == '0') { m = 1; break; } } if (m == 1) { c++; } else if (m == 0) { if (c > k) { k = c; c = 0; } c = 0; } } if (c > k) { k = c; c = 0; } printf("%d\n", k); return 0; }
#include <bits/stdc++.h> using namespace std; string s; int k, old; const int maxn = 1000; int a[maxn]; int main() { int n, d, u = 0; cin >> n >> d; for (int i = 1; i <= d; i++) { cin >> s; k = 0; for (int j = 0; j < s.size(); j++) if (s[j] == '0') { k = 1; break; } if (k == 1) { a[i]++; if (i > 1) a[i] += a[i - 1]; } } for (int i = 1; i <= d; i++) if (a[i] >= old) old = a[i]; cout << old; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { vector<string> vec; int opponents, days; string str, item; bool flag; int winD = 0, ans = 0; scanf("%d %d", &opponents, &days); for (int x = 0; x < days; x++) { cin >> str; vec.push_back(str); } for (int y = 0; y < vec.size(); y++) { item = vec[y]; flag = false; for (int z = 0; z < item.size(); z++) { if (item[z] == '0') { flag = true; break; } else { flag = false; } } if (flag) { winD++; ans = max(ans, winD); } else { ans = max(ans, winD); winD = 0; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int MIN(int a, int b) { return a < b ? a : b; }; int MAX(int a, int b) { return a > b ? a : b; }; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int n, m, q; int flag[110]; int main() { int i, j, k; int m, t, cnt, d; char str[110]; while (~scanf("%d%d", &n, &d)) { getchar(); for (i = 0; i < d; i++) { scanf("%s", str); for (j = 0; str[j] != NULL; j++) { if (str[j] == '0') break; } if (str[j] == NULL) flag[i] = 1; else flag[i] = 0; } m = 0; for (i = 0, cnt = 0; i < d; i++) { if (!flag[i]) { cnt++; } else if (cnt > m) { m = cnt; cnt = 0; } else cnt = 0; } if (cnt > m) m = cnt; printf("%d\n", m); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { vector<long long> v; set<long long> second; long long n, a, c = 0, max = 0; cin >> n >> a; for (int i = 0; i < a; i++) { long long flag = 0; string s; cin >> s; long long l = s.length(); for (int i = 0; i < n; i++) { if (s[i] == '0') { c++; flag = 1; break; } else flag = 0; } if (flag == 1) { if (max <= c) max = c; } else if (flag == 0) c = 0; } cout << max << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, ans = 0; int i, j, a[10000] = {0}, c = 0; string s[10000]; cin >> n >> d; for (i = 0; i < d; i++) { cin >> s[i]; } for (i = 0; i < d; i++) { for (j = 0; j < n; j++) { a[i] += (s[i][j] - '0'); } } for (i = 0; i < d; i++) { if (a[i] < n) { c++; ans = max(ans, c); } else { c = 0; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int op, d; int main() { int nc = 0, bst = 0; ; for (cin >> op >> d; d--;) { string s; cin >> s; int c = 0; for (int i = 0; i < s.size(); ++i) if (s[i] == '1') ++c; if (c == op) nc = 0; else ++nc; bst = max(nc, bst); } cout << bst; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, c = 0, mx = -1; string s; bool flag; cin >> n >> d; for (int i = 0; i < d; i++) { cin >> s; flag = false; for (int j = 0; j < s.length(); j++) { if (s[j] == '0') flag = true; } if (flag) c++; else c = 0; mx = max(mx, c); } cout << mx << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; char s[200]; int ans = 0; int la = 0; bool p; for (int i = 1; i <= d; i++) { cin >> s; p = true; for (int j = 0; j < n; j++) { if (s[j] != '1') { p = false; break; } } if (p) { ans = max(ans, i - la - 1); la = i; } } ans = max(ans, d - la); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, c = 0, m = 0; cin >> n >> d; string s; while (d--) { cin >> s; if (s.find('0') == string::npos) c = 0; else { c++; m = max(m, c); } } cout << m; }
#include <bits/stdc++.h> using namespace std; int a[105][105]; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { scanf("%1d", &a[i][j]); } } int ans = 0; int t = 0; for (int i = 0; i < m; i++) { int flag = 0; for (int j = 0; j < n; j++) { if (a[i][j] == 0) { flag = 1; break; } } if (flag) t++; else t = 0; ans = max(ans, t); } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; string s; int mx = 0; int main() { std::ios::sync_with_stdio(false); int n, d; cin >> n >> d; int ans = 0, ans2 = 0; for (int i = 0; i < d; i++) { ans = 0; for (int j = 0; j < n; j++) { cin >> s[j]; } for (int j = 0; j < n; j++) { if (s[j] == '1') { ans++; } } if (ans < n) { ans2++; } else { ans2 = 0; } mx = max(mx, ans2); } cout << mx << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, d; cin >> n >> d; string s; for (int i = 0; i < n; i++) s += '1'; int ans = 0, cnt = 0; for (int i = 0; i < d; i++) { string s2; cin >> s2; if (s2 == s) cnt = 0; else cnt++, ans = max(ans, cnt); } ans = max(ans, cnt); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> T __sqr(const T x) { return x * x; } template <class T, class X> inline T __pow(T a, X y) { T z = 1; for (int i = 1; i <= y; i++) { z *= a; } return z; } template <class T> inline T gcd(T a, T b) { a = abs(a); b = abs(b); if (!b) return a; return __gcd(b, a % b); } template <class T> inline T lcm(T a, T b) { a = abs(a); b = abs(b); return (a / __gcd(a, b)) * b; } inline bool ispow2(int x) { return (x != 0 && (x & (x - 1)) == 0); } template <class T> void UpdateMin(T &x, T y) { if (y < x) { x = y; } } template <class T> void UpdateMax(T &x, T y) { if (x < y) { x = y; } } template <class T, class X, class Y> inline T bigmod(T n, X m, Y mod) { unsigned long long ret = 1, a = n % mod; while (m) { if (m & 1) ret = (ret * a) % mod; m >>= 1; a = (a * a) % mod; } ret %= mod; return (T)ret; } template <class T, class Y> inline T modinv(T n, Y mod) { return bigmod(n, mod - 2, mod); } template <class T, class X> int getbit(T s, X i) { return (s >> i) & 1; } template <class T, class X> T onbit(T s, X i) { return s | (T(1) << i); } template <class T, class X> T offbit(T s, X i) { return s & (~(T(1) << i)); } template <class T> inline void read(T &n) { char c; for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar()) ; n = c - '0'; for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0'; } void extended_euclid(long long a, long long b, long long &x, long long &y) { if (!b) { x = 1, y = 0; return; } long long first, second; extended_euclid(b, a % b, first, second); x = second; y = first - (a / b) * second; } pair<long long, pair<long long, long long> > extendedEuclid(long long a, long long b) { long long x = 1, y = 0; long long xLast = 0, yLast = 1; long long q, r, m, n; while (a != 0) { q = b / a; r = b % a; m = xLast - q * x; n = yLast - q * y; xLast = x, yLast = y; x = m, y = n; b = a, a = r; } return make_pair(b, make_pair(xLast, yLast)); } const long long mod[] = {0, 1000000007, 1000000009, 1000000021, 1000000033, 1000000097, 1000000093, 1000000097, 1000000103}; const long long base[] = {0, 1000003, 1000033, 1000037, 1000039, 1000081, 1000099, 1000117, 1000121}; char s[(500000 + 20)]; int main() { int n, d, cnt = 0, ans = 0; cin >> n >> d; for (int i = 1; i <= d; i++) { scanf("%s", s + 1); bool chk = false; for (int j = 1; j <= n; j++) { if (s[j] == '0') chk = true; } if (chk) cnt++; else cnt = 0; ans = max(ans, cnt); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { int n, m, cur, best; cin >> m >> n; vector<string> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } cur = 0; best = 0; bool ch; for (int i = 0; i < n; i++) { ch = true; ; for (int j = 0; j < m; j++) { if (a[i][j] == '0') ch = false; } if (cur > best) best = cur; cur++; if (ch == true) cur = 0; } if (cur > best) best = cur; cout << best; }
#include <bits/stdc++.h> using namespace std; int n, d; char str[101]; int main() { cin >> n >> d; int cnt = 0, ans = 0; for (int i = 0; i < d; i++) { cin >> str; if (count(str, str + n, '0') >= 1) cnt++; else cnt = 0; ans = max(cnt, ans); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, d, ans; int main() { cin >> n >> d; int k = 0; for (int i = 0; i < d; i++) { string s; cin >> s; if (s.find("0") != string::npos) { k++; ans = max(ans, k); } else { ans = max(ans, k); k = 0; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x, y, i, j = 0; char ch[200]; cin >> x >> y; int a[y + 1]; memset(a, 0, sizeof(a)); int b = -1; for (i = 0; i < y; i++) { scanf("%s", &ch); int s = 0; int i_1 = 0, i_0 = 0; for (int k = 0; k < strlen(ch); k++) { if (ch[k] == '0') i_0++; } if (i_0 != 0) { if (b == 1) { a[j]++; b = 1; } else { b = 1; j++; a[j]++; } } else b = -1; } sort(a, a + (y + 1)); cout << a[y] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int testCase; string s; int iinf = 1e9 + 1; long long inf = 1e16 + 1; void solve() { long long n; cin >> n; long long d; cin >> d; long long c = 0, ans = 0; for (int i = 0; i < d; i++) { cin >> s; if (count(s.begin(), s.end(), '0')) c++; else { ans = max(ans, c); c = 0; } } ans = max(ans, c); cout << ans; } int main() { testCase = 1; while (testCase--) { solve(); }; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, beat = 0, counts = 0, maxcount = 0, lbeat = 0; cin >> n >> d; char str[n]; for (int i = 0; i < d; i++) { if (lbeat == 0) counts = 0; lbeat = 0; cin >> str; for (int j = 0; j < n; j++) { beat = 0; if (str[j] == '0') { lbeat = 1; beat = 1; break; } } if (beat == 1) counts++; if (counts > maxcount) maxcount = counts; } cout << maxcount; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, ck = 0, m, p = 0; cin >> n >> d; char a[n + 1]; for (int i = 0; i < d; i++) { cin >> a; if (strstr(a, "0") != 0) { ck++; } else if (strstr(a, "1") != 0 && strstr(a, "0") == 0) { m = ck; if (m > p) { p = m; } ck = 0; } } if (ck > p) { cout << ck; return 0; } cout << p; }
#include <bits/stdc++.h> using namespace std; char s[105]; int main() { int n, d; while (~scanf("%d %d", &n, &d)) { int cc = 0; int ans = 0; for (int i = 0; i < d; ++i) { scanf("%s", s); int tmp = 0; for (int i = 0; i < n; ++i) { if (s[i] == '1') tmp++; } if (tmp < n) { cc++; ans = max(ans, cc); } else cc = 0; } printf("%d\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; scanf("%d %d", &n, &d); int ans = 0; int cnt = 0; for (int i = 0; i < d; ++i) { string s; cin >> s; bool valid = false; for (int i = 0; i < n; ++i) if (s[i] == '0') { valid = true; break; } if (valid) { ++cnt; } else cnt = 0; ans = max(ans, cnt); } printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, i, j, k, kd, mk; string a; kd = mk = 0; cin >> n >> d; for (i = 1; i <= d; i++) { cin >> a; k = 0; for (j = 1; j <= n; j++) { if (a[j - 1] == '1') k++; else break; } if (k < n) { kd++; if (kd > mk) mk = kd; } else kd = 0; } if (kd > mk) mk = kd; cout << mk; return 0; }
#include <bits/stdc++.h> using namespace std; string a[123]; bool b[1234]; int pos[1234]; int main() { int m, n; cin >> m >> n; for (int i = 0; i < n; i++) { cin >> a[i]; for (int j = 0; j < m; j++) { if (a[i][j] == '0') { b[i] = 1; break; } } } for (int i = 0; i < n; i++) { if (i == 0) { if (b[i]) pos[i] = 1; else pos[i] = 0; continue; } if (b[i]) { pos[i] = pos[i - 1] + 1; } else pos[i] = 0; } int res = 0; for (int i = 0; i < n; i++) { if (pos[res] < pos[i]) res = i; } cout << pos[res]; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, c = 0, x = 0; string s; cin >> n >> d; for (int i = 0; i < d; i++) { cin >> s; if (s.find('0') == -1) { c = 0; } else c++; if (x < c) x = c; } cout << x; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; string s1 = "111111111111111111111111111111111111111111111111111111111111111111111111" "1111111111111111111111111111"; string s = s1.substr(0, n); pair<string, int> p[d]; for (int i = 0; i < d; i++) { cin >> p[i].first; if (p[i].first == s) { p[i].second = 1; } else { p[i].second = 0; } } int m = 0, x = 0; for (int i = 0; i < d; i++) if (p[i].second == 0) { x++; if (x > m) m = x; } else { x = 0; } cout << m; }
#include <bits/stdc++.h> using namespace std; int n, m; char s[101][101]; int ans1, ans2; int c; int main() { cin >> n >> m; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { cin >> s[i][j]; } } for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (s[i][j] == '0') { c++; break; } else { if (j == n - 1) { if (s[i][j] == '1') { c = 0; } } } } ans2 = max(c, ans2); } cout << ans2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? abs(a) : gcd(b, a % b); } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } int prime[1000000]; void seive() { int n_prime = 1000000; fill_n(prime, n_prime, 1); prime[0] = 0; prime[1] = 0; for (int i = 2; i * i <= n_prime; i++) { if (prime[i]) { for (int j = i * i; j <= n_prime; j += i) { prime[j] = 0; } } } } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, d, id; std::cin >> n >> d; char c; vector<int> ans; for (int i = 0; i < d; i++) { id = 0; for (int j = 0; j < n; j++) { std::cin >> c; if (c == '0') { id = 1; } } ans.push_back(id); } id = 0; int ma = 0, sum = 0; for (auto i : ans) { if (i == 1 && id == 0) { sum++; id = 1; } else if (i == 1 && id == 1) { sum++; } else if (i == 0 && id == 1) { ma = max(ma, sum); id = 0; sum = 0; } } if (id == 1 && ans[(int)ans.size() - 1] == 1) { ma = max(ma, sum); } std::cout << ma << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int flag; string stri; int max = 0, var = 0; int n, d; cin >> n >> d; for (int i = 0; i < d; i++) { flag = 0; cin >> stri; for (int j = 0; j < n; j++) { if (stri[j] != '1') flag = 1; } if (flag == 0) { var = 0; } else { var++; } if (var > max) { max = var; } } cout << max << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; t = 1; while (t--) { int n; int d; cin >> n >> d; string s[105]; for (int i = 0; i < d; i++) cin >> s[i]; int ans = -1; int cur = 0; for (int i = 0; i < d; i++) { int flag = 0; for (int j = 0; j < s[i].size(); j++) { if (s[i][j] == '0') { flag = 1; break; } } if (flag == 0) { ans = max(cur, ans); cur = 0; } else cur++; } ans = max(cur, ans); cout << ans << "\n"; } }
#include <bits/stdc++.h> using namespace std; int main() { char a[105]; int arya[105]; int n, d; cin >> n >> d; int add = 0; int maxi = 0; if (cin.fail()) { cin.clear(); cin.ignore(32767, '\n'); } for (int i = 0; i < d; ++i) { int sum = 0; for (int j = 0; j < n; ++j) { cin >> a[j]; if (a[j] == '0') arya[i] = 1; else sum++; } if (sum == n) arya[i] = 0; for (int j = 0; j < d; ++j) { if (arya[j] == 1) { add++; maxi = max(maxi, add); } else add = 0; } } cout << maxi << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int oo = (int)1e9; const double PI = 2 * acos(0.0); const double eps = 1e-7; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; int main() { int n, m; cin >> n >> m; string s; int mx = 0; int c = 0; for (int i = 0; i < m; i++) { cin >> s; int va = 0; for (int l = 0; l < ((int)((s).size())); l++) if (s[l] == '0') { c++; va = 1; break; } if (va == 0) { mx = max(mx, c); c = 0; } } cout << max(mx, c) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; while (cin >> n >> d) { int ans = 0; int tmp = 0; string str; while (d--) { cin >> str; int c = 0; for (int i = 0; i < n; i++) { c += (str[i] == '1') ? 1 : 0; } if (c < n) { tmp++; } else { tmp = 0; } ans = max(ans, tmp); } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> int main() { int n, day, max = 0, count = 0, flag; char enemy[101]; scanf("%d %d", &n, &day); for (int q = 1; q <= day; q++) { flag = 1; scanf("%s", enemy); for (int w = 0; w < n; w++) { if (enemy[w] == '0') { flag = 0; break; } } if (flag == 0) { count++; } else if (flag == 1) { if (count > max) { max = count; } count = 0; } } if (count > max) { max = count; } printf("%d\n", max); }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; string arr[150]; for (int i = 0; i < d; i++) { cin >> arr[i]; } int flag = 0, con = 0; int res = 0; for (int i = 0; i < d; i++) { for (int j = 0; j < n; j++) { if (arr[i][j] == '1') { flag = 1; } else { flag = 0; break; } } if (flag == 0) { con++; if (con > res) res = con; } else { if (con > res) res = con; con = 0; } } cout << res << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, d, ans, maxi; string str; cin >> n >> d; ans = maxi = 0; for (i = 0; i < d; i++) { cin >> str; if (str.find('0') == string::npos) { ans = max(maxi, ans); maxi = 0; } else maxi++; } ans = max(maxi, ans); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, c = 0, maxi = 0, sum = 0; char a; cin >> d >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < d; j++) { cin >> a; sum += a - '0'; } if (sum == d) { maxi = max(c, maxi); c = 0; } else { c++; } sum = 0; } maxi = max(c, maxi); cout << maxi << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int const MAXN = 100; int arr[MAXN]{}; bool win(int n) { char s; int ans = 0; for (int i = 0; i < n; i++) { cin >> s; if (s == '1') { ans++; } } return ans != n; } int main() { int n, d; cin >> n >> d; int ans = 0; int temp = 0; for (int i = 0; i < d; i++) { if (win(n)) { temp++; } else { temp = 0; } if (temp > ans) ans = temp; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 2; const int M = 1e5 + 2; const int mod = 1e9 + 7; const int inf = 1e9; const long long INF = 1e16; void data() {} template <typename T> void scerr(T nums) { for (auto it : nums) cerr << it << " | "; cerr << "\n"; } int n, ans, d, t, tmp; string cnt; int main() { data(); scanf("%d %d", &d, &n); for (int i = 1; i <= n; ++i) { cin >> cnt; tmp = 0; for (auto l : cnt) tmp += (l == '1'); if (tmp == d) { ans = max(ans, t); t = 0; } else { t++; } ans = max(ans, t); } printf("%d", ans); }
#include <bits/stdc++.h> using namespace std; int n, d, sum, ans; char s[105]; int main() { scanf("%d %d", &n, &d); for (int i = 0; i < d; i++) { scanf("%s", s); bool ok = true; for (int j = 0; j < n; j++) if (s[j] == '0') ok = false; if (ok) sum = 0; else sum++, ans = max(ans, sum); } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; long long int pow1(long long int a, long long int b) { if (b == 0) return 1; if (b == 1) return a; long long temp; if (b % 2 == 0) { temp = pow1(a, b / 2); temp = temp % 1000000007; temp = temp * temp; temp = temp % 1000000007; return temp; } else { temp = pow1(a, b / 2); temp = temp % 1000000007; temp = temp * temp; temp = temp % 1000000007; temp = temp * a; temp = temp % 1000000007; return temp; } } int main() { long long n, d, i; scanf("%lld", &n); scanf("%lld", &d); long long ans[10002]; for (i = 0; i < 1002; i++) { ans[i] = 0; } for (i = 0; i < d; i++) { string temp; cin >> temp; long long j; for (j = 0; j < n; j++) { if (temp[j] == '0') { ans[i] = 1; } } } long long ans1 = 0; long long cnt = 0; for (i = 0; i < d; i++) { if (ans[i] == 1) { cnt++; } else { cnt = 0; } if (cnt > ans1) ans1 = cnt; } printf("%lld\n", ans1); return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, m, ans = 0, count = 0; cin >> n >> m; string s; while (m--) { cin >> s; if (s.find('0') == -1) count = 0; else { count++; ans = max(ans, count); } } cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d, b[100000] = {0}; cin >> n >> d; for (int i = 0; i < d; i++) { string a = {}; cin >> a; int k = 0; while (1) { if (a[k] == '0') { b[i] = 1; break; } else k++; if (k >= n) break; } } int dem = 0, max = 0; for (int i = 0; i <= d; i++) { if (b[i] == 1) dem++; else { if (max < dem) max = dem; dem = 0; } } cout << max; }
#include <bits/stdc++.h> using namespace std; int main() { int i, d, n; int ans = 0; cin >> n >> d; string s[d]; for (i = 0; i < d; i++) cin >> s[i]; int f[d], j; for (i = 0; i < d; i++) { f[i] = 0; for (j = 0; j < n; j++) { if (s[i][j] == '0') { f[i] = 1; break; } } } int sum = 0; for (i = 0; i < d; i++) { sum += f[i]; ans = max(ans, sum); if (f[i] == 0) sum = 0; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; while (cin >> n >> d) { int ans = 0; int mx = 0; for (int i = 0; i < d; i++) { bool f = 0; for (int j = 0; j < n; j++) { char c; cin >> c; if (c == '0') f = 1; } if (f) { mx++; ans = max(ans, mx); } else mx = 0; } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int worker() { int n, d; scanf("%d%d", &n, &d); int mxrun = 0; int currun = 0; for (int i = 0; i < d; i++) { string s; cin >> s; if (s.find('0') != string::npos) currun++; else { mxrun = max(mxrun, currun); currun = 0; } } mxrun = max(mxrun, currun); return mxrun; } int main() { cout << worker() << endl; int xx; cin >> xx; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = int(2e5 + 5); const int INF = 1e9 + 7; const long long inf = 1e18; int n, m; int main() { cin >> n >> m; int cur = 0, ans = 0; for (int i = 1; i <= m; ++i) { char ch; set<char> st; for (int j = 1; j < 2; ++j) { string s; cin >> s; st.insert(s.begin(), s.end()); ch = s[0]; } if (st.size() == 1) { if (ch == '1') { ans = max(ans, cur); cur = 0; } else { ++cur; } } else { ++cur; } } ans = max(ans, cur); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, d; string s; cin >> n >> d; int cnt = 0, cnt2 = 0, out = 0; for (int i = 0; i < d; i++) { cin >> s; cnt2 = 0; for (int j = 0; j < s.length(); j++) { if (s[j] != '1') { cnt++; break; } else cnt2++; } if (cnt2 == s.length()) { if (cnt > out) out = cnt; cnt2 = 0; cnt = 0; } else if (cnt > out) out = cnt; } cout << out << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, d, j, a[1000] = {}, l = 0, cnt = 0, max = 0; cin >> n >> d; string s; for (i = 0; i < d; i++) { cin >> s; for (j = 0; j < n; j++) { if (s[j] == '0') { a[l] = i + 1; l++; break; } } } for (i = 0; i < l; i++) { if (a[i] == a[i + 1] - 1) { cnt++; if (max < cnt) max = cnt; } else cnt = 0; } if (l == 0) cout << max; else cout << max + 1; }
#include <bits/stdc++.h> using namespace std; const int MAX = 105; int n, d; char pre; int v[MAX]; int main() { scanf("%d %d", &n, &d); for (int i = 0; i < d; i++) { bool f = true; for (int j = 0; j < n; j++) { scanf(" %c", &pre); if (pre == '0') f = false; } if (!f) v[i] = 0; else v[i] = 1; } int ans = INT_MIN, tmp = 0; for (int i = 0; i < d; i++) { if (v[i] == 1) { ans = max(ans, tmp); tmp = 0; } else { tmp++; } } ans = max(ans, tmp); printf("%d\n", ans); }
#include <bits/stdc++.h> using namespace std; int n, c; int a[205]; vector<int> e[205]; int d[205][205], f[205][205], p[205], b[205]; void dfs(int k, int fa) { for (int i = 0; i < n; ++i) { f[k][i] = a[d[k][i]] + c; } for (int i = 0; i < e[k].size(); ++i) { int u = e[k][i]; if (fa == u) continue; dfs(u, k); for (int j = 0; j < n; ++j) { f[k][j] += min(f[u][j] - c, f[u][p[u]]); } } p[k] = 0; for (int i = 1; i < n; ++i) { if (f[k][i] < f[k][p[k]]) { p[k] = i; } } } void print(int k, int fa, int ans) { b[k] = ans + 1; for (int i = 0; i < e[k].size(); ++i) { int u = e[k][i]; if (fa == u) continue; if (f[u][ans] - c < f[u][p[u]]) { print(u, k, ans); } else { print(u, k, p[u]); } } } int main() { scanf("%d%d", &n, &c); for (int i = 1; i < n; ++i) { scanf("%d", &a[i]); } memset(d, 10, sizeof(d)); int x, y; for (int i = 0; i < n - 1; ++i) { scanf("%d%d", &x, &y); --x; --y; e[x].push_back(y); e[y].push_back(x); d[x][y] = d[y][x] = 1; } for (int i = 0; i < n; ++i) { d[i][i] = 0; } for (int k = 0; k < n; ++k) { for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } dfs(0, -1); printf("%d\n", f[0][p[0]]); print(0, -1, p[0]); for (int i = 0; i < n; ++i) { printf("%d ", b[i]); } return 0; }