QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#624053 | #8046. Rock-Paper-Scissors Pyramid | REN5511 | WA | 0ms | 3604kb | C++14 | 1.9kb | 2024-10-09 14:50:01 | 2024-10-09 14:50:02 |
Judging History
answer
#include <iostream>
#include <vector>
using namespace std;
string tar;
char win(char p1,char p2) {
if (p1 == 'S') {
if (p2 == 'S') {
return 'S';
}
else if (p2 == 'P') {
return 'S';
}
else {
return 'R';
}
}
else if (p1 == 'P') {
if (p2 == 'S') {
return 'S';
}
else if (p2 == 'P') {
return 'P';
}
else {
return 'P';
}
}
else {
if (p2== 'S') {
return 'R';
}
else if (p2 == 'P') {
return 'P';
}
else {
return 'R';
}
}
return '$';
}
char solve(int l,int r) {
if (r - l+1 <= 2) {
return win(tar[r], tar[l]);
}
int midl = (l + r) / 2, midr = (l + r) / 2 + 1;
if ((r - l + 1) % 2) {
int mid = midl;
midl--;
char a= solve(l, midl), b= solve(midr, r);
return win(win(a, tar[mid]), win(b, tar[mid]));
//if (win(a, tar[mid]) != tar[mid]) {
// return a;
//}
//else if (win(b, tar[mid]) != tar[mid]) {
// return b;
//}
//else {
// return win(win(a, tar[mid]), win(b, tar[mid]));
//}
}
else {
//char who = win(tar[midl], tar[midr]);
return win(solve(l, midl), solve(midr, r));
//if (who == tar[midl] && who == tar[midr]) {
// return win(solve(l, midl), solve(midr, r));
//}
//else if (who == tar[midl]) {
// return solve(l, midl);
//}
//else {
// return solve(midr, r);
//}
}
}
int main()
{
int t;
cin >> t;
while (t--) {
cin >> tar;
tar = '$' + tar;
cout<<solve(1, tar.size()-1)<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3604kb
input:
2 SPR SPSRRP
output:
S S
result:
wrong answer 2nd lines differ - expected: 'P', found: 'S'