QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#446463 | #8523. Puzzle II | PhantomThreshold | WA | 1ms | 3772kb | C++17 | 1.0kb | 2024-06-17 11:02:03 | 2024-06-17 11:02:04 |
Judging History
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]