QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#624234 | #8046. Rock-Paper-Scissors Pyramid | REN5511 | WA | 19ms | 5220kb | C++14 | 1.2kb | 2024-10-09 15:17:58 | 2024-10-09 15:17:59 |
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 '$';
}
int main()
{
int t;
cin >> t;
while (t--) {
cin >> tar;
char who,atk;
who = tar[0], atk = tar[0];
for (auto i : tar) {
if (win(i, atk) == who) {
who = win(i, atk);
atk = i;
}
else if (win(i, atk) == i&&i!=atk) {
atk = i; who = i;
}
}
cout << who << "\n";
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
2 SPR SPSRRP
output:
S P
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 19ms
memory: 5220kb
input:
1 RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...
output:
P
result:
wrong answer 1st lines differ - expected: 'R', found: 'P'