QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#620214 | #8046. Rock-Paper-Scissors Pyramid | mhw# | WA | 7ms | 6212kb | C++20 | 1.5kb | 2024-10-07 17:01:53 | 2024-10-07 17:01:54 |
Judging History
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'