/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 4ms 772.0 KiB
#3 Accepted 2ms 540.0 KiB
#4 Accepted 2ms 540.0 KiB
#5 Accepted 2ms 540.0 KiB
#6 Accepted 2ms 840.0 KiB
#7 Accepted 2ms 796.0 KiB
#8 Accepted 2ms 844.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define f(i,x,y) for(int i=x;i<y;i++)
#define f2(i,x,y) for(int i=x;i>=y;i--)
#define pii pair<int,int>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int MOD =1000000007;
const int INF = 1e18;
const int N = 2e5;

void solve(int tc){
    int n; cin >> n;
    string s; cin >>s;
    int mx = 0;
    for(int i=0;i<n;){
        int j=i,cnt=1;
        while(j+1<n and s[j]==s[j+1]){
            j++;
            cnt++;
        }
        if(s[i]=='0')mx = max(mx,cnt);
        i=j+1;
    }
    cout << mx << endl;
    // if(n==1){
    //     if(s[0]=='0')cout << 1 << endl;
    //     else cout << 0 << endl;
    //     return;
    // }
    // int z , o; z = o = 0;
    // for(auto it : s){
    //     z+=it=='0';
    //     o+=it=='1';
    // }
    // if(o==n){
    //     cout << 0 << endl;
    //     return;
    // }
    // if(z==n){
    //     cout << n << endl;
    //     return;
    // }

}
int32_t main(){

    Fast

    int t=1;

    cin >> t;

    for(int tc=1;tc<=t;tc++){

        solve(tc);
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1113 Fliping Game
Contest
Brain Booster #7
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-05 14:56:28
Judged At
2024-11-05 14:56:28
Judged By
Score
100
Total Time
4ms
Peak Memory
844.0 KiB