QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#617401 | #8046. Rock-Paper-Scissors Pyramid | Juro | WA | 4ms | 4132kb | C++17 | 1.2kb | 2024-10-06 15:22:21 | 2024-10-06 15:22:22 |
Judging History
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;
}
详细
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'