QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#727354 | #8046. Rock-Paper-Scissors Pyramid | Arkhell | WA | 15ms | 6204kb | C++14 | 1.4kb | 2024-11-09 12:54:40 | 2024-11-09 12:54:41 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
string s;
cin>>s;
string tmp;
for(int i=1;i<s.length();i++){
if(s[i]=='S'){
if(s[i-1]=='R'){
tmp+='R';
}
else{
tmp+='S';
}
}
else if(s[i]=='R'){
if(s[i-1]=='P'){
tmp+='P';
}
else{
tmp+='R';
}
}
else{
if(s[i-1]=='S'){
tmp+='S';
}
else{
tmp+='P';
}
}
}
char ans=tmp[0];
for(int i=1;i<tmp.length();i++){
if(tmp[i]=='S'){
if(ans=='R'){
ans='R';
}
else{
ans='S';
}
}
else if(tmp[i]=='R'){
if(ans=='P'){
ans='P';
}
else{
ans='R';
}
}
else{
if(ans=='S'){
ans='S';
}
else{
ans='P';
}
}
}
cout<<ans<<'\n';
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3768kb
input:
2 SPR SPSRRP
output:
S P
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 15ms
memory: 6204kb
input:
1 RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...
output:
P
result:
wrong answer 1st lines differ - expected: 'R', found: 'P'