QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#742230 | #8046. Rock-Paper-Scissors Pyramid | zcc | TL | 0ms | 3760kb | C++17 | 787b | 2024-11-13 16:08:09 | 2024-11-13 16:08:10 |
Judging History
answer
#include<bits/stdc++.h>
#define N 1000005
using namespace std;
int t,top;
char s[N],st[N];
bool spr(char a,char b)
{
if(a=='S')return b=='P';
if(a=='P')return b=='R';
return b=='S';
}
int main()
{
scanf("%d",&t);
while(t--){
scanf("%s",s);
top=0;
for(int i=0;i<strlen(s);i++){
char x=s[i];
if(top==0){
st[top++]=x;
}else{
if(st[top-1]==x)continue;
if(spr(st[top-1],x)){
st[top++]=x;
}else{
top--;
if(top==0)st[top++]=x;
}
}
//printf("\t%s\n",st);
}
printf("%c\n",st[0]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3760kb
input:
2 SPR SPSRRP
output:
S P
result:
ok 2 lines
Test #2:
score: -100
Time Limit Exceeded
input:
1 RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...