QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#617816 | #8046. Rock-Paper-Scissors Pyramid | tomatoss | WA | 17ms | 6688kb | C++17 | 2.0kb | 2024-10-06 17:14:22 | 2024-10-06 17:14:23 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[1010], b[1010];
int n;
double t = 0.3331321335578;
double ct = 0;
void solve() {
ct += t;
cout << ct << '\n';
}
void find(string st) {
string s = "";
for (auto u : st) {
//cout<<s.back()<<" "<<u<<'\n';
if (u != s.back())s += u;
}
int l = 0, r = 0;
for (int i = 2; i < s.size(); i++) {
if (s.substr(i - 2, 3) == "RSP") {
l = 1;
break;
}
if (s.substr(i - 2, 3) == "PRS") {
l = 2;
break;
}
if (s.substr(i - 2, 3) == "SPR") {
l = 3;
break;
}
}
reverse(s.begin(),s.end());
for (int i = 2; i < s.size(); i++) {
//cout<<s.substr(i - 2, 3)<<'\n';
if (s.substr(i - 2, 3) == "RSP") {
r = 1;
break;
}
if (s.substr(i - 2, 3) == "PRS") {
r = 2;
break;
}
if (s.substr(i - 2, 3) == "SPR") {
r = 3;
break;
}
}
//cout<<l<<" "<<r<<'\n';
if(l == 0&&r == 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';
};
win(s[0],s[1]);
cout<<s[0]<<'\n';
return;
}
if(r == 0){
if (l == 1)cout << 'R' << '\n';
else if (l == 2)cout << 'P' << '\n';
else cout << 'S' << '\n';
return;
}
if(l == 0){
if (r == 1)cout << 'R' << '\n';
else if (r == 2)cout << 'P' << '\n';
else cout << 'S' << '\n';
return;
}
if (l == r) {
if (l == 1)cout << 'R' << '\n';
else if (l == 2)cout << 'P' << '\n';
else cout << 'S' << '\n';
return;
}
if (l == 1) {
if (r == 2) {
cout << "P" << '\n';
}
else {
cout << "R" << '\n';
}
}
else if (l == 2) {
if (r == 1) {
cout << "P" << '\n';
}
else {
cout << "S" << '\n';
}
}
else {
if (r == 1) {
cout << "R" << '\n';
}
else {
cout << "S" << '\n';
}
}
}
signed main() {
int t; cin >> t;
while (t--) {
string s;
cin >> s;
find(s);
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
2 SPR SPSRRP
output:
S P
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 17ms
memory: 6688kb
input:
1 RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...
output:
P
result:
wrong answer 1st lines differ - expected: 'R', found: 'P'