QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#477934#8832. Daily DisinfectionRosmontispesWA 3ms3488kbC++20883b2024-07-14 13:19:452024-07-14 13:19:45

Judging History

This is the latest submission verdict.

  • [2024-07-14 13:19:45]
  • Judged
  • Verdict: WA
  • Time: 3ms
  • Memory: 3488kb
  • [2024-07-14 13:19:45]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
#define fi first
#define se second
void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<pii>ar;
    int mn = 0x3f3f3f3f,sum = 0;
    for(int i = 0;i < (int)s.size();i ++)
    {
        int j = i;
        while(j + 1 < (int)s.size() && s[j + 1] == s[i])
            j ++;
        ar.push_back({s[i] - '0',j - i + 1});
        if(s[i] - '0' == 1)
            mn = min(mn,j - i + 1),sum += j - i + 1;
        i = j;
    }
    if(ar[0].fi == 1 && ar.back().fi == 1){
        if(mn == 0x3f3f3f3f)
            cout<<"0\n";
        else
            cout<<sum + mn<<"\n";
    }
    else
        cout<<sum<<"\n";
    

}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T;
    cin>>T;
    while(T --)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3484kb

input:

3
2
01
5
00110
9
101010101

output:

1
2
6

result:

ok 3 number(s): "1 2 6"

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3488kb

input:

10000
15
010111111011011
10
1000101111
10
0011111101
1
0
3
110
4
1000
8
10000111
20
00000101000100001110
13
1101110110110
13
0111100011010
17
00001001111110101
1
0
20
10001010011000111100
11
00100110101
11
10110101000
15
001011110011000
16
1110111110000111
15
011110110110010
1
0
20
10110001101100010...

output:

11
7
7
0
2
1
5
6
9
7
9
0
9
5
5
7
14
9
0
10
8
7
3
6
0
6
2
5
4
9
10
4
6
1
8
2
1
8
1
8
12
9
15
4
12
13
16
6
4
4
5
1
1
7
8
5
4
0
0
11
9
5
6
7
6
4
9
1
4
5
12
0
2
10
4
3
7
7
3
7
5
3
7
9
15
2
6
7
9
8
6
1
2
6
2
11
10
5
0
0
4
7
4
10
0
4
7
9
3
3
10
3
6
12
8
1
8
6
5
2
4
9
7
1
6
8
8
3
5
12
6
10
8
8
9
16
2
7
6
4...

result:

wrong answer 2nd numbers differ - expected: '6', found: '7'