QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#620214#8046. Rock-Paper-Scissors Pyramidmhw#WA 7ms6212kbC++201.5kb2024-10-07 17:01:532024-10-07 17:01:54

Judging History

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

  • [2024-10-07 17:01:54]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:6212kb
  • [2024-10-07 17:01:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 P = 998244353;
void solve() {
    string s;
    cin >> s;
    string ss = "";
    ss += s[0];
    for (int i = 1; i < s.length(); i++) {
        if (ss.back() == s[i]) continue;
        ss += s[i];
    }
    s = ss;
    if (s.length() == 1) {
        cout << s << '\n';
        return;
    }
    string t = "";
    int n = s.length();
    auto cmp = [&](char x, char y) -> bool {
        if (x == 'S' && y == 'P') return true;
        else if (x == 'P' && y == 'R') return true;
        else if (x == 'R' && y == 'S') return true;
        return false;
    };
    if (cmp(s[0], s[1])) t += s[0];
    for (int i = 1; i < n - 1; i++) {
        if (!cmp(s[i], s[i - 1]) && !cmp(s[i], s[i + 1])) {
            continue;
        } else {
            t += s[i];
        }
    }
    if (cmp(s[n - 1], s[n - 2])) t += s[n - 1];
    ss = "";
    ss += t[0];
    for (int i = 1; i < t.length(); i++) {
        if (ss.back() == t[i]) continue;
        ss += t[i];
    }
    t = ss;
    // cout << t << '\n';
    if (t.size() == 1) {
        cout << t << '\n';
    } else if (cmp(t[0], t[1])) {
        cout << t[0] << '\n';
    } else {
        cout << t.back() << '\n';
    }
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--) solve();
    return 0;
}
/*
100
5
SPR
SPSRRP
SSRSPSRP
PSSPRSSSS
SSPSRPSPR
*/

詳細信息

Test #1:

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

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 6212kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

P

result:

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