QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#471109#8832. Daily Disinfectionucup-team3519#WA 2ms3816kbC++20854b2024-07-10 18:10:162024-07-10 18:10:17

Judging History

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

  • [2024-07-10 18:10:17]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3816kb
  • [2024-07-10 18:10:16]
  • 提交

answer

#pragma GCC optimize(3,"Ofast","inline")
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
#define ll long long
const int N=300005;
const ll mod=998244353;
ll qpow(ll a,ll b){
	ll ans=1;
	if(b==0)
	return 1;
	if(b%2)
	ans=a;
	ll t=qpow(a,b/2);
	return t*t%mod*ans%mod;
}
ll inv(ll a){
	return qpow(a,mod-2);
}
void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	int cur=0;
	int mn=n;
	for(int i=0;i<n;i++){
	
		if(s[i]=='1'){
			cur++;
			cnt++;
		}
		if(i==n-1||s[i+1]=='0'){
			mn=min(mn,cur);
		}
	}
	if(cnt==0){
		cout<<0<<'\n';
	}
	else if(s[0]=='0'||s[n-1]=='0'){
		cout<<cnt<<'\n';
	}
	else{
		cout<<cnt+mn<<'\n';
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int t0;
	cin>>t0;
	for(int t=0;t<t0;t++){
		solve();
	}
}

詳細信息

Test #1:

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

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: 2ms
memory: 3816kb

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

result:

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