QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#742150#8046. Rock-Paper-Scissors PyramidzccTL 0ms3888kbC++17787b2024-11-13 15:59:172024-11-13 15:59:18

Judging History

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

  • [2024-11-13 15:59:18]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3888kb
  • [2024-11-13 15:59:17]
  • 提交

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: 3888kb

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: -100
Time Limit Exceeded

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:


result: