QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#756084#9565. Birthday GiftL_wwqqWA 0ms3576kbC++20781b2024-11-16 18:59:172024-11-16 18:59:17

Judging History

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

  • [2024-11-16 18:59:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3576kb
  • [2024-11-16 18:59:17]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define i128 __int128
#define fi first
#define se second
#define all(a) begin(a)+1,end(a)
typedef unsigned long long ull;
using namespace std;
using pii = pair<int,int>;
using piii = pair<int,pii>;
const int N = 1e6+5;

int n,m,k;

inline void beez(){
	string s;
	cin >> s;
	int n0 = 0,n1 = 0,n2 = 0;
	bool ok = true;
	for(auto it : s){
		if(it == '2') n2 ++;
		else if(it == '0' and ok) n0 ++;
		else n1 ++;
		ok = !ok;
	}
	int tmp = abs(n0 - n1);
	if(tmp > n2) cout << tmp - n2 << "\n";
	else {
		tmp -= n2;
		if(tmp & 1) cout << "1\n";
		else cout << "0\n";
	}
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int __=1;
	cin>>__;
	while(__--){
		beez();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3576kb

input:

5
0110101
01020102
0000021111
1012121010
0100202010

output:

5
0
2
6
2

result:

wrong answer 1st numbers differ - expected: '3', found: '5'