QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#446466#8523. Puzzle IIPhantomThresholdWA 0ms3816kbC++171.0kb2024-06-17 11:02:532024-06-17 11:02:53

Judging History

This is the latest submission verdict.

  • [2024-06-17 11:02:53]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3816kb
  • [2024-06-17 11:02:53]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

int n,k;
string strA,strB;
vector<pair<int,int>> ans;

int main(){
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	cin >> strA >> strB;
	char colA='B';
	char colB='C';
	
	int sum=0;
	for (auto ch:strA) if (ch==colA) sum++;
	if (sum+sum<n){
		swap(colA,colB);
		sum=n-sum;
	}
	
	deque<char> qA,qB;
	int stA=0,edA=k,stB=0,edB=k-1;
	for (int i=0;i<k+1;i++) qA.push_back(strA[i]);
	for (int i=0;i<k;i++) qB.push_back(strB[i]);
	for (;sum<n;sum++){
		for (;qA.front()==colA;){
			stA=(stA+1)%n;
			edA=(edA+1)%n;
			qA.pop_front();
			qA.push_back(strA[edA]);	
		}
		for (;qB.back()==colB;){
			stB=(stB+1)%n;
			edB=(edB+1)%n;
			qB.pop_front();
			qB.push_back(strB[edB]);	
		}
		ans.emplace_back((stA+1)%n,stB);
		ans.emplace_back(stA,stB);
		qB.push_front(qA.front());
		qA.pop_front();
		qA.push_back(qB.back());
		qB.pop_back();
	}
	
	cout << (int)ans.size() << "\n";
	for (auto [x,y]:ans){
		cout << x+1 << " " << y+1 << "\n";	
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3552kb

input:

6 3
BCCBCC
BBCBBC

output:

4
2 1
1 1
4 4
3 4

result:

ok moves = 4

Test #2:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

2 1
BC
BC

output:

2
1 1
2 1

result:

ok moves = 2

Test #3:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

2 1
BB
CC

output:

0

result:

ok moves = 0

Test #4:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

2 1
CC
BB

output:

0

result:

ok moves = 0

Test #5:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

3 1
CCC
BBB

output:

0

result:

ok moves = 0

Test #6:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

3 1
CBC
BCB

output:

2
3 2
2 2

result:

ok moves = 2

Test #7:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

3 2
BBB
CCC

output:

0

result:

ok moves = 0

Test #8:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

3 2
BCB
BCC

output:

2
3 3
2 3

result:

ok moves = 2

Test #9:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

4 2
CCCB
BBCB

output:

2
1 2
4 2

result:

ok moves = 2

Test #10:

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

input:

9 6
CCCBCCCBB
BBBCBBBCC

output:

6
5 3
4 3
8 4
7 4
8 8
7 8

result:

wrong answer The final sequences are not correct!