QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#475045#8832. Daily Disinfectionucup-team3646#WA 9ms3572kbC++201.9kb2024-07-13 10:44:302024-07-13 10:44:32

Judging History

你现在查看的是最新测评结果

  • [2024-07-13 10:44:32]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:3572kb
  • [2024-07-13 10:44:30]
  • 提交

answer

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

#define ll long long
#define elif else if
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int,int>


#define repname(a, b, c, d, e, ...) e
#define rep(...)                    repname(__VA_ARGS__, rep3, rep2, rep1, rep0)(__VA_ARGS__)
#define rep0(x)                     for (int rep_counter = 0; rep_counter < (x); ++rep_counter)
#define rep1(i, x)                  for (int i = 0; i < (x); ++i)
#define rep2(i, l, r)               for (int i = (l); i < (r); ++i)
#define rep3(i, l, r, c)            for (int i = (l); i < (r); i += (c))





struct ScalarInput {
    template<class T>
    operator T(){
        T ret;
        cin >> ret;
        return ret;
    }
};
struct VectorInput {
    size_t n;
    VectorInput(size_t n): n(n) {}
    template<class T>
    operator vector<T>(){
        vector<T> ret(n);
        for(T &x : ret) cin >> x;
        return ret;
    }
};
ScalarInput input(){ return ScalarInput(); }
VectorInput input(size_t n){ return VectorInput(n); }

template<typename T>
void print(vector<T> a){
  for(int i=0;i<a.size();i++){
    cout<<a[i]<<" \n"[i+1==a.size()];
  }
}

template<class T>
void print(T x){
    cout << x << '\n';
}
 
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail){
  cout << head << ' ';
  print(forward<Tail>(tail)...);
}

void solve(){
  ll N;
  string S;
  cin>>N>>S;
  ll cnt=0;
  bool Z=0;
  ll k=0;
  ll cnos=1e18;
  rep(i,N){
    if(S[i]=='1'){
      cnt++;
      k++;
    }
    else{
      if(k!=0)cnos=min(cnos,k);
      k=0;
      if(i!=0&&S[i-1]=='0')Z=1;
    }
    
  }
  if(S[0]=='0'||S.back()=='0'||Z){
    cout<<cnt<<endl;
  }
  else {
    cout<<cnt+cnos<<endl;
  }
}

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

  ll T;
  cin>>T;
  rep(t,T)solve();

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 9ms
memory: 3504kb

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
6
7
0
2
1
4
6
9
7
9
0
9
5
5
7
11
9
0
9
8
7
3
6
0
6
2
5
4
8
10
4
6
1
7
2
1
8
1
8
11
9
13
4
11
13
16
6
4
4
5
1
1
7
7
5
3
0
0
11
8
5
6
7
6
4
9
1
4
5
12
0
2
10
5
3
7
7
3
7
4
3
7
9
15
2
6
6
9
8
6
1
2
6
2
11
10
5
0
0
4
7
4
7
0
4
7
9
3
3
10
3
6
11
8
1
13
6
5
2
4
9
7
1
5
7
8
3
5
11
6
10
8
8
9
16
2
7
6
4
...

result:

wrong answer 75th numbers differ - expected: '4', found: '5'