QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#446463#8523. Puzzle IIPhantomThresholdWA 1ms3772kbC++171.0kb2024-06-17 11:02:032024-06-17 11:02:04

Judging History

This is the latest submission verdict.

  • [2024-06-17 11:02:04]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3772kb
  • [2024-06-17 11:02:03]
  • 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<n/2){
		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: 1ms
memory: 3768kb

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: 1ms
memory: 3768kb

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: 1ms
memory: 3612kb

input:

2 1
CC
BB

output:

0

result:

ok moves = 0

Test #5:

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

input:

3 1
CCC
BBB

output:

0

result:

ok moves = 0

Test #6:

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

input:

3 1
CBC
BCB

output:

4
2 1
1 1
1 3
3 3

result:

wrong answer Integer 4 violates the range [0, 3]