QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#820437#4592. TheramoreSGColinAC ✓6ms3788kbC++201.0kb2024-12-18 21:26:532024-12-18 21:26:53

Judging History

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

  • [2024-12-18 21:26:53]
  • 评测
  • 测评结果:AC
  • 用时:6ms
  • 内存:3788kb
  • [2024-12-18 21:26:53]
  • 提交

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