QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#771132#8046. Rock-Paper-Scissors PyramidcaiwenWA 0ms3516kbC++14939b2024-11-22 10:03:252024-11-22 10:03:30

Judging History

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

  • [2024-11-22 10:03:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3516kb
  • [2024-11-22 10:03:25]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define ull unsigned long long
#define ls(k) (k)<<1
#define rs(k) (k)<<1|1
#define debug(x) cout<<#x<<"="<<x<<endl
using namespace std;
const int inf=0x3f3f3f3f3f3f3f3f;
const int mod=0;
typedef pair<int,int> pii;
inline void subtask(){
    deque<char> q;
    string str;cin>>str;
    int n=str.size();
    q.push_front(str[0]);
    for(int i=2;i<=n;i++){
        char now=str[i-1],top=q.front();
        if(
            (now=='S'&&top=='P')||
            (now=='P'&&top=='R')||
            (now=='R'&&top=='S')
        ){
            q.pop_front();
        }
        while(!q.empty()&&now==q.front()) q.pop_front();
        q.push_front(now);
        if(q.size()==3){
            return cout<<q.back(),void();
        }
    }
    cout<<q.back();
}
signed main(){
    ios::sync_with_stdio(false);
    int t;cin>>t;
    while(t--) subtask();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3516kb

input:

2
SPR
SPSRRP

output:

SP

result:

wrong answer 1st lines differ - expected: 'S', found: 'SP'