QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#508900 | #8046. Rock-Paper-Scissors Pyramid | 333zhan | RE | 26ms | 25756kb | C++20 | 1.7kb | 2024-08-07 21:39:15 | 2024-08-07 21:39:15 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read () {
int w = 1, s = 0; char ch = getchar ();
for (; ! isdigit (ch); ch = getchar ()) if (ch == '-') w = -1;
for (; isdigit (ch); ch = getchar ()) s = (s << 1) + (s << 3) + (ch ^ 48);
return s * w;
}
bool fight (int x, int y) {
if (x == 1 && y == 3) {
return true;
}
if (x == 2 && y == 1) {
return true;
}
if (x == 3 && y == 2) {
return true;
}
return false;
}
void solve () {
string s;
cin >> s;
const int n = s.size ();
int change[200];
change['S'] = 1;
change['R'] = 2;
change['P'] = 3;
vector <int> a;
for (auto c : s) {
a.push_back (change[c]);
}
for (int i = 1; i < n && a.size () > 1; i ++) {
// for (auto x : a) {
// cout << x << " ";
// }
// cout << '\n';
vector <int> b;
for (int j = 0; j < a.size () - 1; j ++) {
if (a[j] == a[j + 1]) {
continue;
} else if (fight (a[j], a[j + 1])) {
b.push_back (a[j]);
} else {
b.push_back (a[j + 1]);
}
}
a.swap (b);
}
if (a[0] == 1) {
cout << 'S' << '\n';
} else if (a[0] == 2) {
cout << 'R' << '\n';
} else {
cout << 'P' << '\n';
}
}
signed main () {
ios::sync_with_stdio (false);
cin.tie (nullptr);
int T = 1;
cin >> T;
// T = read ();
while (T --) {
solve ();
}
return 0;
}
/*
1 2 3
剪刀 石头 布
2 3 1 2 3 1 1 3
1 2 3 1 2 3 1 3 2
2 2
1 2 1
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3776kb
input:
2 SPR SPSRRP
output:
S P
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 26ms
memory: 25756kb
input:
1 RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...
output:
R
result:
ok single line: 'R'
Test #3:
score: 0
Accepted
time: 11ms
memory: 19840kb
input:
1 PPPPPSPPPRPPPPRRPSRPPRSSRPPPPPPRPPPPRPPSPPPPPPPRPPRRPPRPPSPPPPRRPSPRSPPPPPPRRRPRPRPPPPPPRPPPPPPPSPPPPPPPPRPPPPSPPRPPPPPSPPRPPPSRPPPPRPPRPPRPPPSPPPPPPPRPPRRPPSPRPRPPPPPRPPPPPPPRPRRRSPPPPPSPSPSRPRPSPSPPPPPRSPPPPPRPPPRPPPPPPSRRRPPPPRPSPPSRPPRPPRPPPRRSPPPRRRPPRPPPPPRPPPSPRPPRPPPRPSPPPRPPPPPRRPPSPRPRPR...
output:
P
result:
ok single line: 'P'
Test #4:
score: -100
Runtime Error
input:
500 SSSPSSSPRPSPPPPRRPSPSRSPSPPSRPPRRRSRRSPRPRRRRPSSPPRRSPPPSRRSPSPRRSSPPSRPRPPSSPSSRSSSRRSSPSSRSRRPSPSRSSRSRRPRRRPSSPPPSRPSSPPSSPSSPPRRPPRSPSRSRPRRSSRSSRPRRPRSRRPPRRPPRRRRRRRSRSSRPPSRRRPRRPSRPPPPSRSSPPPPSPPPRPPPPPRSRPPRSRPRRPPPRSRRRSSPRSSPPSRRPPPSRPSPSPRSRPRRPSSRPPRRSPSPPPSPPRRPPPRSRSSSRSPRRPSRSRSP...