QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#525457 | #8046. Rock-Paper-Scissors Pyramid | WJX3078 | WA | 12ms | 8756kb | C++14 | 955b | 2024-08-20 16:47:47 | 2024-08-20 16:47:52 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#define il inline
#define ll long long
#define gc getchar
using namespace std;
il int read() {
int x=0;bool f=0;char ch=gc();
while(!isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=gc();}
while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=gc();}
return f?-x:x;
}
const int N=1e6+10;
int T,n;
char a[N];
int b[N];
signed main() {
T=read();
while(T--) {
scanf("%s",a);
int n=strlen(a);
for(int i=0;i<n;++i) {
if(a[i]=='R') b[i+1]=0;
if(a[i]=='P') b[i+1]=1;
if(a[i]=='S') b[i+1]=2;
}
bool f=0;
int ans=b[1];
for(int i=1;i<n;++i) {
if(b[i+1]==(ans-1+3)%3) {f=1;continue;}
if(b[i+1]==ans) {f=0;continue;}
if(b[i+1]==(ans+1)%3) {
if(f) continue;
else {
ans=b[i+1];
f=0;
}
}
}
if(ans==0) printf("R\n");
if(ans==1) printf("P\n");
if(ans==2) printf("S\n");
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5808kb
input:
2 SPR SPSRRP
output:
S P
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 12ms
memory: 8756kb
input:
1 RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...
output:
P
result:
wrong answer 1st lines differ - expected: 'R', found: 'P'