QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#794765 | #8527. Power Divisions | wangjunrui | WA | 0ms | 3808kb | C++14 | 1.7kb | 2024-11-30 15:56:13 | 2024-11-30 15:56:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 3e5 + 5;
int n, m;
char A[N], B[N];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> m >> A >> B;
int cnt = 0;
for (int i = 0; i < n; ++i)
cnt += (A[i] == 'B');
list<char> a, b;
for (int i = 0; i < m; ++i)
a.push_back(A[i]);
for (int i = n - m; i < n; ++i)
b.push_back(B[i]);
b.push_back(B[0]);
vector<pair<int, int>> answer;
if (cnt <= n / 2)
{
for (int i = m - 1, j = 0; cnt--;)
{
while (a.front() != 'B')
{
A[(i - a.size() + 1 + n) % n] = a.front();
a.pop_front();
a.push_back(A[i = (i + 1) % n]);
}
while (b.back() != 'C')
{
B[(j - b.size() + 1 + n) % n] = b.front();
b.pop_front();
b.push_back(B[j = (j + 1) % n]);
}
answer.emplace_back((i - m + 1 + n) % n, (j - m + n) % n);
answer.emplace_back((i - m + 1 + n) % n, (j - m + 1 + n) % n);
a.pop_front(), b.pop_back();
a.push_back('C'), b.push_front('B');
}
}
else
{
cnt = n - cnt;
for (int i = m - 1, j = 0; cnt--;)
{
while (a.front() != 'C')
{
A[(i - a.size() + 1 + n) % n] = a.front();
a.pop_front();
a.push_back(A[i = (i + 1) % n]);
}
while (b.back() != 'B')
{
B[(j - b.size() + 1 + n) % n] = b.front();
b.pop_front();
b.push_back(B[j = (j + 1) % n]);
}
answer.emplace_back((i - m + 1 + n) % n, (j - m + n) % n);
answer.emplace_back((i - m + 1 + n) % n, (j - m + 1 + n) % n);
a.pop_front(), b.pop_back();
a.push_back('B'), b.push_front('C');
}
}
cout << answer.size() << '\n';
for (auto [u, v] : answer)
cout << u + 1 << ' ' << v + 1 << '\n';
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3808kb
input:
5 2 0 0 1 1
output:
0
result:
wrong answer 1st numbers differ - expected: '6', found: '0'