QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#820437 | #4592. Theramore | SGColin | AC ✓ | 6ms | 3788kb | C++20 | 1.0kb | 2024-12-18 21:26:53 | 2024-12-18 21:26:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
inline int rd() {
int x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}
#define N 100007
char s[N];
int even[2], odd[2];
inline void work() {
odd[0] = odd[1] = even[0] = even[1] = 0;
scanf("%s", s + 1);
int n = strlen(s + 1);
for (int i = 1; i <= n; ++i) {
if (i & 1) ++odd[s[i] - '0'];
else ++even[s[i] - '0'];
}
for (int i = 1; i <= n; ++i) {
if (i & 1) {
if (odd[0]) {putchar('0'); --odd[0];}
else putchar('1');
} else {
if (even[0]) {putchar('0'); --even[0];}
else putchar('1');
}
}
puts("");
}
int main() {
for (int t = rd(); t; --t) work();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 6ms
memory: 3788kb
input:
10 101001 01101100000000101010 11100100010110110011101010011111111010110100011100000001101011111001101000001010101001101101010011100101001000001011111011010001111110100101100010111110011000000101110110110001010100110001000110001101110011001101101101011000011010011010101111010010111010001001010111111...
output:
001011 00000000001010101111 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok 10 lines