QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#794667#8523. Puzzle IIwangjunruiWA 0ms3556kbC++141.6kb2024-11-30 15:27:022024-11-30 15:27:06

Judging History

This is the latest submission verdict.

  • [2024-11-30 15:27:06]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3556kb
  • [2024-11-30 15:27:02]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
constexpr int N = 1.5e5 + 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');
	
	deque<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--; ++i)
		{
			while (a.front() != 'B')
			{
				a.pop_front();
				a.push_back(A[i = (i + 1) % n]);
			}
			while (b.back() != 'C')
			{
				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();
			swap(a, b);
			a.push_back('C');
			b.push_front('B');
		}
	}
	else
	{
		cnt = n - cnt;
		for (int i = m - 1, j = 0; cnt--; ++i)
		{
			while (a.front() != 'C')
			{
				a.pop_front();
				a.push_back(A[i = (i + 1) % n]);
			}
			while (b.back() != 'B')
			{
				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();
			swap(a, b);
			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: 3556kb

input:

6 3
BCCBCC
BBCBBC

output:

4
1 6
1 1
3 6
3 1

result:

wrong answer The final sequences are not correct!