/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 4ms 584.0 KiB
#3 Accepted 2ms 320.0 KiB
#4 Accepted 2ms 568.0 KiB
#5 Accepted 2ms 580.0 KiB
#6 Accepted 2ms 744.0 KiB
#7 Accepted 2ms 788.0 KiB
#8 Accepted 2ms 696.0 KiB

Code

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define arr_for(n) for (int i = 0; i < n; i++)
#define arrj_for(n) for (int j = 0; j < n; j++)
#define rev_arr_for(n) for (int i = n - 1; i >= 0; i--)
#define for_one(n) for (int i = 1; i <= n; i++)
#define pf push_front
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define newl "\n"
using namespace std;

void solve() {
    ll n;
    cin >> n;

    string str;
    cin >> str;

    int cnt = 0, maxx = 0;

    for (int i = 0; i < str.length(); i++) {
        if (str[i] == '0' and str[i + 1] == '0')
            cnt++;
        else
            cnt = 0;

        maxx = max(maxx, cnt);
    }

    cout << (count(all(str), '0') == 0 ? 0 : maxx + 1) << newl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

#ifdef ONPC
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int testcase = 1;
    cin >> testcase;

    while (testcase--) {
        solve();
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1113 Fliping Game
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-06 11:36:46
Judged At
2024-11-11 02:25:09
Judged By
Score
100
Total Time
4ms
Peak Memory
788.0 KiB