QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#617401#8046. Rock-Paper-Scissors PyramidJuroWA 4ms4132kbC++171.2kb2024-10-06 15:22:212024-10-06 15:22:22

Judging History

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

  • [2024-10-06 15:22:22]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:4132kb
  • [2024-10-06 15:22:21]
  • 提交

answer

#include <bits/stdc++.h>

using LL = long long;
#define F(i, x, y) for (std::decay<decltype(y)>::type i = (x), _##i = (y); i <= _##i; ++i)
#define dF(i, x, y) for (std::decay<decltype(y)>::type i = (x), _##i = (y); i >= _##i; --i)

using ld = long double;
const ld PI = acos(-1);
constexpr ld EPS = 1e-7;
constexpr ld INF = std::numeric_limits<ld>::max();
#define cc(x) std::cout << std::fixed << std::setprecision(x);

template <class T, class S>
bool equal(T x, S y)
{
    return abs(x - y) < EPS;
}

constexpr int N = 2e6 + 26;
constexpr int MOD = 998244353;

void solve()
{
    std::string s;
    std::cin >> s;
    char ans = s[0];
    auto win = [&](char &x, char y) {
        if (x == 'S' && y == 'R') x = 'R';
        else if (x == 'R' && y == 'P') x = 'P';
        else if (x == 'P' && y == 'S') x = 'S';
    };
    for (int i = 1; i < s.size(); ++i) {
        char c1 = s[i - 1];
        char c2 = s[i];
        win(c1, c2);
        win(ans, c1);
    }
    std::cout << ans << '\n';
}

int main(void)
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int _;
    std::cin >> _;
    while (_--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 4132kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

P

result:

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