QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#44315#4592. TheramoreGemini7XAC ✓56ms3948kbC++20525b2022-08-15 15:50:452022-08-15 15:50:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-15 15:50:48]
  • 评测
  • 测评结果:AC
  • 用时:56ms
  • 内存:3948kb
  • [2022-08-15 15:50:45]
  • 提交

answer

#include<bits/stdc++.h>
#define MAX 100005
using namespace std;
int n;
char s[MAX];
vector<int> v1,v2;
void solve(){
	scanf("%s",s+1);n=strlen(s+1);
	v1.clear();v2.clear();
	for(int i=1;i<=n;i++){
		if(i&1) v1.push_back(s[i]-'0');
		else v2.push_back(s[i]-'0');
	}
	sort(v1.begin(),v1.end());sort(v2.begin(),v2.end());
	int h1=0,h2=0;
	for(int i=1;i<=n;i++){
		if(i&1) printf("%d",v1[h1++]);
		else printf("%d",v2[h2++]);
	}printf("\n");
}
int main(){
	int T;scanf("%d",&T);
	while(T--) solve();
	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 56ms
memory: 3948kb

input:

10
101001
01101100000000101010
11100100010110110011101010011111111010110100011100000001101011111001101000001010101001101101010011100101001000001011111011010001111110100101100010111110011000000101110110110001010100110001000110001101110011001101101101011000011010011010101111010010111010001001010111111...

output:

001011
00000000001010101111
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 10 lines