QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#768168#8523. Puzzle IIucup-team004WA 0ms3616kbC++231.5kb2024-11-21 01:26:242024-11-21 01:26:33

Judging History

This is the latest submission verdict.

  • [2024-11-21 01:26:33]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3616kb
  • [2024-11-21 01:26:24]
  • Submitted

answer

#include <bits/stdc++.h>

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n, k;
    std::cin >> n >> k;
    
    std::string s, t;
    std::cin >> s >> t;
    
    std::vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        a[i] = s[i] == 'B' ? 0 : 1;
        b[i] = t[i] == 'B' ? 0 : 1;
    }
    
    int a0 = std::count(a.begin(), a.end(), 0);
    if (a0 > n - a0) {
        a0 = n - a0;
        for (int i = 0; i < n; i++) {
            a[i] ^= 1;
            b[i] ^= 1;
        }
    }
    
    int c = 0, d = 0;
    std::deque<int> as, bs;
    for (int i = 0; i < k; i++) {
        as.push_back(a[i]);
    }
    for (int i = 0; i < k + 1; i++) {
        bs.push_back(b[i]);
    }
    
    std::cout << 2 * a0 << "\n";
    for (int _ = 0; _ < a0; _++) {
        while (a[0] != 0) {
            a[(c + k - 1) % n] = as.back();
            as.pop_back();
            c = (c + n - 1) % n;
            as.push_front(a[c]);
        }
        while (bs.back() != 1) {
            b[(d + k) % n] = bs.back();
            bs.pop_back();
            d = (d + n - 1) % n;
            bs.push_front(b[d]);
        }
        std::cout << c + 1 << " " << d + 1 << "\n";
        std::cout << c + 1 << " " << (d + 1) % n + 1 << "\n";
        as.pop_front();
        as.push_back(1);
        bs.pop_back();
        bs.push_front(0);
    }
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 3
BCCBCC
BBCBBC

output:

4
1 6
1 1
1 4
1 5

result:

wrong answer The final sequences are not correct!