QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#91894#4592. Theramorebosun#AC ✓8ms3824kbC++11488b2023-03-29 20:42:102023-03-29 20:42:13

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-29 20:42:13]
  • 评测
  • 测评结果:AC
  • 用时:8ms
  • 内存:3824kb
  • [2023-03-29 20:42:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
char s[100005];
int main(){
	int t,n;
	cin>>t;
	while(t--){
		scanf("%s",s+1);
		n=strlen(s+1);
		int i,cnt1=0,cnt2=0;
		for(i=1;i<=n;i+=2){
			cnt1+=(s[i]=='1');
		}
		for(i=2;i<=n;i+=2){
			cnt2+=(s[i]=='1');
		}
		for(i=n-(n%2);i>=2;i-=2)
			if(i>=n-n%2-2*(cnt2-1))s[i]='1';
			else s[i]='0';
		for(i=n+(n%2)-1;i>=1;i-=2)
			if(i>=n-n%2-1-2*(cnt1-1))s[i]='1';
			else s[i]='0';
		printf("%s\n",s+1);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 8ms
memory: 3824kb

input:

10
101001
01101100000000101010
11100100010110110011101010011111111010110100011100000001101011111001101000001010101001101101010011100101001000001011111011010001111110100101100010111110011000000101110110110001010100110001000110001101110011001101101101011000011010011010101111010010111010001001010111111...

output:

001011
00000000001010101111
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 10 lines