QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#163641#6860. Binary Numberjrjyy#WA 27ms3648kbC++20764b2023-09-04 13:22:402023-09-04 13:22:41

Judging History

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

  • [2023-09-04 13:22:41]
  • 评测
  • 测评结果:WA
  • 用时:27ms
  • 内存:3648kb
  • [2023-09-04 13:22:40]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int n;
    i64 k;
    std::cin >> n >> k;

    std::string s;
    std::cin >> s;

    if (n == 1) {
        s[0] ^= k % 2;
    } else {
        i64 c = 0;
        for (int l = 0, r; c < k && l < n; l = r) {
            for (; l < n && s[l] == '1'; ++l);
            for (r = l; r < n && s[r] == '0'; ++r);
            std::fill(s.begin() + l, s.begin() + r, '1');
            ++c;
        }
        if (k == 1 && c == k) {
            s.back() = '0';
        }
    }

    std::cout << s << '\n';
}

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

    int t;
    std::cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 27ms
memory: 3648kb

input:

59471
11 523478562876
11011111010
10 1000
1110101110
11 13333
10101000011
11 9
10000001001
11 1000
10110100100
11 4
11000010111
11 1000
11100100011
11 100
10000000001
11 23333
10111101110
9 233
110110010
11 648953764538
10011110011
9 233333
101010111
11 9
10001011001
11 8
10100001100
10 77777777
100...

output:

11111111111
1111111111
11111111111
11111111111
11111111111
11111111111
11111111111
11111111111
11111111111
111111111
11111111111
111111111
11111111111
11111111111
1111111111
11111111111
11111111111
11111111010
11111111111
11111111111
11111111111
11111111111
11111111000
11111111111
1111010
1111111111...

result:

wrong answer 78th lines differ - expected: '1110111111', found: '1110111110'