Submission #3235244


Source Code Expand

#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const int MAXN = 123456;
char s[MAXN];

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    if (n == 1) {
       printf("1\n");
       return 0;
    }
    int cnt0 = 0, cnt1 = 0;
    if (s[1] == '1') cnt1 = 1;
    else cnt0 = 1;
    int ans = 0;
    for (int i = 2; i <= n; i++) {
        ans = max({ans, cnt0, cnt1});
        if (s[i] == s[i - 1]) {
           if (s[i] == '1') cnt1++;
           else cnt0++;
        } else {
           if (s[i] == '1') cnt1 = 1, cnt0 = 0;
           else cnt0 = 1, cnt1 = 0;
        }
    }
    ans = max({ans, cnt0, cnt1});
    if (ans < 2 && n > 2) ans = 2;
    printf("%d\n", ans);
    return 0;
}

Submission Info

Submission Time
Task D - Wide Flip
User BOT
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1001 Byte
Status WA
Exec Time 2 ms
Memory 384 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", s + 1);
                       ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 14
WA × 16
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt WA 2 ms 384 KB
02.txt WA 2 ms 384 KB
03.txt WA 2 ms 384 KB
04.txt WA 2 ms 384 KB
05.txt WA 2 ms 384 KB
06.txt WA 2 ms 384 KB
07.txt WA 2 ms 384 KB
08.txt WA 2 ms 384 KB
09.txt WA 2 ms 384 KB
10.txt WA 2 ms 384 KB
11.txt WA 2 ms 384 KB
12.txt WA 2 ms 384 KB
13.txt WA 2 ms 384 KB
14.txt WA 2 ms 384 KB
15.txt WA 2 ms 384 KB
16.txt WA 2 ms 384 KB
17.txt AC 2 ms 384 KB
18.txt AC 2 ms 384 KB
19.txt AC 2 ms 384 KB
20.txt AC 2 ms 384 KB
21.txt AC 1 ms 256 KB
22.txt AC 1 ms 256 KB
23.txt AC 1 ms 256 KB
24.txt AC 1 ms 256 KB
25.txt AC 1 ms 256 KB
26.txt AC 1 ms 256 KB
27.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 1 ms 256 KB