QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#791919#9565. Birthday Giftimwinter#WA 0ms3620kbC++20957b2024-11-28 21:57:492024-11-28 21:57:53

Judging History

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

  • [2024-11-28 21:57:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-11-28 21:57:49]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void sol() {
    std::string s;
    std::cin >> s;

    int cnt = 0, cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '2') cnt2++;
        if (i % 2 == 0) {
            if (s[i] == '0') {
                cnt1++;
            } else if (s[i] == '1') {
                cnt++;
            }
        } else {
            if (s[i] == '0') {
                cnt++;
            } else if (s[i] == '1') {
                cnt1++;
            }
        }
    }
    if (cnt2 >= std::abs(cnt1 - cnt)) {
        std::cout << cnt2 % 2 << "\n";
        return;
    }
    std::cout << std::min(std::abs(cnt2 - std::abs(cnt1 - cnt)),std::abs(cnt1 - cnt) + cnt2 % 2) << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int _ = 1;
    std::cin >> _;

    while (_--) {
        sol();
    }

    return 0;
}

詳細信息

Test #1:

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

input:

5
0110101
01020102
0000021111
1012121010
0100202010

output:

3
4
1
6
0

result:

wrong answer 3rd numbers differ - expected: '0', found: '1'