QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#768168 | #8523. Puzzle II | ucup-team004 | WA | 0ms | 3616kb | C++23 | 1.5kb | 2024-11-21 01:26:24 | 2024-11-21 01:26:33 |
Judging History
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;
}
詳細信息
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!