QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#624234#8046. Rock-Paper-Scissors PyramidREN5511WA 19ms5220kbC++141.2kb2024-10-09 15:17:582024-10-09 15:17:59

Judging History

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

  • [2024-10-09 15:17:59]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:5220kb
  • [2024-10-09 15:17:58]
  • 提交

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'