QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#401117#5075. Fenwick TreeAlphaMale06WA 11ms3576kbC++14723b2024-04-27 22:15:122024-04-27 22:15:12

Judging History

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

  • [2024-04-27 22:15:12]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3576kb
  • [2024-04-27 22:15:12]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define int long long


void solve(){
	int n;
	string s;
	cin >> n >> s;
	bool mark[n];
	for(int i=0; i< n; i++){
		mark[i]=0;
	}
	int ans=0;
	for(int i=0; i< n; i++){
		if(s[i]=='0' && mark[i] || s[i]=='1' && !mark[i]){
			ans++;
			for(int x = i+1; x<=n; x+=x&-x)mark[x-1]=1;
		}
	}
	cout << ans << '\n';
}


signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	cin >> t;
	while(t--){
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
5
10110
5
00000
5
11111

output:

3
0
3

result:

ok 3 number(s): "3 0 3"

Test #2:

score: -100
Wrong Answer
time: 11ms
memory: 3496kb

input:

100000
10
0000000000
10
0000000100
10
0000000000
10
1000000000
10
0000010000
10
0000000000
10
0000000000
10
0000000000
10
0100000000
10
0000000000
10
0000000001
10
0000001000
10
0000000000
10
0000000000
10
0000000001
10
0000100000
10
0010000000
10
0000000000
10
0010000000
10
0000000001
10
0000000000...

output:

0
1
0
4
2
0
0
0
3
0
1
2
0
0
1
3
3
0
3
1
0
0
2
2
3
0
2
3
3
0
3
2
0
0
4
2
0
0
2
0
3
3
0
0
0
0
0
0
0
2
3
3
2
0
1
0
2
2
0
2
3
0
2
4
0
1
0
2
0
0
3
3
0
0
0
1
3
0
2
0
0
0
0
2
2
0
0
0
0
0
0
2
0
2
2
0
3
4
2
0
0
0
0
0
0
0
1
0
0
0
4
0
2
0
0
0
2
0
3
0
0
2
0
0
0
1
0
0
1
2
0
0
2
0
3
0
0
2
0
3
0
0
0
3
0
0
3
3
1
0
...

result:

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