/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 20ms 576.0 KiB
#3 Wrong Answer 4ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007
#define ll long long
#define INF LLONG_MIN




void solve() {
     int t;
    cin >> t;
    while (t--) {
        int n;
        string s;
        cin >> n >> s;
        int ans=1,mx=1,cnt=0;
        for(int i=0;i<n-1;i++)
        {
            if(s[i]=='1')
            {
                cnt++;
            }
            if(s[i]==s[i+1])
            {
                ans++;
            }
            else
            {
                
                mx=max(mx,ans);
                ans=1;
            }

        }
        mx=max(mx,ans);
        if(s[n-1]=='1')
        cnt++;
        if(cnt!=n)
        cout<<mx<<endl;
        else
        cout<<0<<endl;
        
        
    }
    
    
}

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

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    solve();
    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 15:19:28
Judged At
2024-11-05 15:19:28
Judged By
Score
5
Total Time
20ms
Peak Memory
576.0 KiB