QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#610248#8046. Rock-Paper-Scissors PyramiddaaiRE 56ms5244kbC++14958b2024-10-04 15:23:242024-10-04 15:23:33

Judging History

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

  • [2024-10-04 15:23:33]
  • 评测
  • 测评结果:RE
  • 用时:56ms
  • 内存:5244kb
  • [2024-10-04 15:23:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N=4e5+107;
int n,q;
string s;

int read()
{
	int f=1,s=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=(s<<1)+(s<<3)+(ch^48);ch=getchar();}
	return f*s;
}

char compare(char x,char y)
{
	if(y<x) swap(x,y);
	
	if(x=='P'&&y=='R') return x;
	else if(x=='R'&&y=='S') return x;
	else if(x=='P'&&y=='S') return y;
	else return x;
}

bool comp(char x,char y)
{
	if(x=='P'&&y=='R') return 1;
	if(x=='R'&&y=='S') return 1;
	if(x=='S'&&y=='P') return 1;
	return 0;
}

char st[N];
int tp;
int query(int l,int r)
{
	tp=0;
	for(int i=l;i<=r;i++)
	{
		while(tp>0&&comp(s[i],st[tp])) tp--;
		st[++tp]=s[i];
	}
	return st[1];
}

int main()
{
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int T=read();
	while(T--)
	{
		cin>>s; 
		n=s.size();
		s=' '+s;
		printf("%c\n",query(1,n));
	}
	
}

详细

Test #1:

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

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 21ms
memory: 5208kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

R

result:

ok single line: 'R'

Test #3:

score: 0
Accepted
time: 11ms
memory: 5172kb

input:

1
PPPPPSPPPRPPPPRRPSRPPRSSRPPPPPPRPPPPRPPSPPPPPPPRPPRRPPRPPSPPPPRRPSPRSPPPPPPRRRPRPRPPPPPPRPPPPPPPSPPPPPPPPRPPPPSPPRPPPPPSPPRPPPSRPPPPRPPRPPRPPPSPPPPPPPRPPRRPPSPRPRPPPPPRPPPPPPPRPRRRSPPPPPSPSPSRPRPSPSPPPPPRSPPPPPRPPPRPPPPPPSRRRPPPPRPSPPSRPPRPPRPPPRRSPPPRRRPPRPPPPPRPPPSPRPPRPPPRPSPPPRPPPPPRRPPSPRPRPR...

output:

P

result:

ok single line: 'P'

Test #4:

score: 0
Accepted
time: 21ms
memory: 3732kb

input:

500
SSSPSSSPRPSPPPPRRPSPSRSPSPPSRPPRRRSRRSPRPRRRRPSSPPRRSPPPSRRSPSPRRSSPPSRPRPPSSPSSRSSSRRSSPSSRSRRPSPSRSSRSRRPRRRPSSPPPSRPSSPPSSPSSPPRRPPRSPSRSRPRRSSRSSRPRRPRSRRPPRRPPRRRRRRRSRSSRPPSRRRPRRPSRPPPPSRSSPPPPSPPPRPPPPPRSRPPRSRPRRPPPRSRRRSSPRSSPPSRRPPPSRPSPSPRSRPRRPSSRPPRRSPSPPPSPPRRPPPRSRSSSRSPRRPSRSRSP...

output:

S
R
R
S
S
P
P
R
P
S
R
R
P
R
S
P
S
S
P
S
R
R
P
S
S
S
R
R
S
R
S
R
R
R
P
P
P
R
R
P
R
S
P
S
S
S
P
S
R
P
S
P
R
R
S
P
P
P
R
S
S
R
S
P
R
R
R
S
R
R
P
R
R
R
P
R
P
S
R
P
P
P
P
P
S
S
P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R
SS...

output:

P
P
S
P
R
R
R
P
R
R
P
P
S
S
P
P
P
R
P
P
P
S
S
S
P
P
P
P
R
S
S
R
P
P
P
S
R
S
R
R
P
R
S
S
S
P
P
S
S
P
S
S
P
P
S
P
S
P
P
P
R
S
P
P
R
S
S
R
S
R
S
P
S
R
R
P
P
P
P
R
R
R
S
S
R
S
P
P
S
R
R
R
R
S
S
R
P
R
R
R
R
S
P
S
S
R
S
P
S
S
P
R
R
R
R
P
S
S
P
S
P
R
R
P
S
R
P
R
S
S
P
R
R
P
P
R
P
S
R
S
S
S
S
P
P
S
P
R
S
R
...

result:

ok 130000 lines

Test #10:

score: 0
Accepted
time: 31ms
memory: 3668kb

input:

35000
RSRPRPSRSPRRPSPSRPSSRRSPPP
SSRPPRSSRSRRSPPSSSRSSPPR
SRPRSPSPPPSRRPSPPPRRRSRRRSPRS
PSRRSPRSSRPPSRPPPPPRSPSSSSPPSRSPSPRPSSRSSS
SPRRRSSPRRSRPSPRPSRRRSR
RPSRRRSRSRRSRPPSSRPSRRPRS
PSRRSPRRPSRPSSRPSSRPPRRPRRPRR
PRPRPRRPPPRRRSSSPSSSRPPRSRPSSP
RRPPPPPSSSPPPPRPPSPSRRPPSRRRPSPP
SRPSSSRPRPSRSPSRPRSRRPPRR...

output:

R
P
S
P
S
P
P
S
S
P
R
P
R
S
R
S
S
P
P
R
R
R
P
S
P
S
S
S
S
S
R
S
S
R
S
R
R
P
S
S
P
R
P
P
R
P
R
S
S
P
P
R
S
S
P
S
R
S
P
P
S
R
S
R
S
P
R
R
S
R
S
S
S
S
S
S
S
R
P
R
P
R
P
P
S
R
R
S
R
P
S
P
S
R
R
R
P
P
R
P
R
R
R
R
S
S
R
R
R
P
R
P
P
P
R
P
S
R
R
S
S
R
S
S
S
S
R
P
P
P
P
R
R
S
S
R
R
S
R
R
S
P
P
P
S
P
S
P
P
P
...

result:

ok 35000 lines

Test #11:

score: 0
Accepted
time: 22ms
memory: 3868kb

input:

5000
SPSRPPRPRRPS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S
R
S
S
S
S
R
R
R
R
S
R
R
P
S
S
R
S
R
R
S
R
P
P
P
P
P
P
R
S
R
P
P
R
S
P
R
S
S
S
P
P
R
P
R
R
P
P
S
P
S
R
R
P
P
P
S
R

result:

ok 100 lines

Test #13:

score: 0
Accepted
time: 21ms
memory: 4192kb

input:

8
SRRSRSRSPPPSPSSRSRRSRPSRRPSPSSPPRRRPPPSPSRPSSRPSPRPPPPPRSPSSPSSRRRPSRPPSSPRPRPRPSRPPSPRPSSPSRPSRRPSPRSSSSRSPSPPPRPSSPRRPSPRSSPSSRSPRRSRRSSSPRRPRPRPRRPRPSPSRPPRSSPSPSPSRPSPPRRRSRRSPSPRSSPSPSPRPPRPPRRPSSRPRRSPSPRRPRRPPRSRSRPSSSSRRPPPRPRSSPSRPPPPRRPSRSRPRSRPRSRRRRSRSSPSSPPRPSRPRRSPRSSPRPPSPRRRRPRRPSP...

output:

P
R
P
S
P
S
R
S

result:

ok 8 lines

Test #14:

score: 0
Accepted
time: 14ms
memory: 5244kb

input:

1
RRRSPRRSSPSPRPPSSSSPPSRPSPRPPSSSRRSSSSRSSSPSRPSPPPPSPRSPSSSSSPPSSRRPRSSSRRSPSRRRSPSPSRRPRSPRRSPPPSPSRSPPPRSPSSRSSRPRPPSPRSPSRPRPSSPPRPSRPRPSPSRSSRSSPRRRSPRPPPPSPPPSRRSPRPSPPRSPPSPPSRPRSPPSPRRSRSRSRSPSSPPPPPRRPSSRSRRPRSSRPSPPRPPPSPSSSSRPSPRSSPSRRRPPSSSPPRSSSRPRRSPPPRRPSPPRPPSPSRRRPPPPRRPPRSSRSSPPRS...

output:

P

result:

ok single line: 'P'

Test #15:

score: 0
Accepted
time: 19ms
memory: 3832kb

input:

4
PRSRPRSPSRPRPRSRPSPRSPSPSRSPSPSRSRSRSPSRSPSRSPRSRPRPRSRSRPSPSRPRSRPRSRPRPRPSRSRSRSPSRPSRSPRSPSPRSPRPSRPRPRPSRPSPSRSPRPRPSPRPRSPRPSRPRPRSRSPRPRSPSPRSPRSRSPRPSRSPSPRSPSPRPRPRSPRSPSPSPRPSRPRSPSRSPRSPSPRPRPRPSRPRPSRSRPRSRPRPRPSRPSPRPRSRSRSRPSRPRPRPRPSRSPSPSRSRPSPSPSPRPRPRSRPRSRPSRPSPRPSPSRPRSRSRSRPSPR...

output:

S
R
R
S

result:

ok 4 lines

Test #16:

score: 0
Accepted
time: 19ms
memory: 4376kb

input:

3
SRPRPSPSPRSRPRSRSPRSRPRSRPRPRPSPRSRSRPSPRSPSPRSRSPRPSPSPRPSRSPRPRPSRPRSRPSPSRSPSRPSRPRSRPSPSRSPRSRSPRSPRPSPSPSPRPRSPSRPSRSRPSRSRSPSPRSRPSRPRSRSPRSPSRSPSPRSRPRSPSPRPRPRSRPRPSPRSRPSPRPRSRPRSRSRPSPSRSPRPSRPRPSPSRPRPRSPRSPSPSRPRPSRPRPSPSPRPSPRPRSRPRSPSRSPRPRSRPSPSRSRSRPRSPSRSPSPSRSPRPSRPSPSRPRPRSPRPSR...

output:

S
P
P

result:

ok 3 lines

Test #17:

score: -100
Runtime Error

input:

1
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

output:


result: