QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#727354#8046. Rock-Paper-Scissors PyramidArkhellWA 15ms6204kbC++141.4kb2024-11-09 12:54:402024-11-09 12:54:41

Judging History

你现在查看的是最新测评结果

  • [2024-11-09 12:54:41]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:6204kb
  • [2024-11-09 12:54:40]
  • 提交

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'