QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624201#8046. Rock-Paper-Scissors PyramidREN5511WA 18ms5260kbC++141.2kb2024-10-09 15:13:462024-10-09 15:13:47

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 15:13:47]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:5260kb
  • [2024-10-09 15:13:46]
  • 提交

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) {
                atk = i; who = i;
            }
        }
        cout << who << "\n";
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 18ms
memory: 5260kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

P

result:

wrong answer 1st lines differ - expected: 'R', found: 'P'