QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#771137#8046. Rock-Paper-Scissors PyramidcaiwenWA 0ms4188kbC++14951b2024-11-22 10:04:582024-11-22 10:04:59

Judging History

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

  • [2024-11-22 10:04:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4188kb
  • [2024-11-22 10:04:58]
  • 提交

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()<<endl,void();
        }
    }
    cout<<q.back()<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    int t;cin>>t;
    while(t--) subtask();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3588kb

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 4188kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

P

result:

wrong answer 1st lines differ - expected: 'R', found: 'P'