QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#525457#8046. Rock-Paper-Scissors PyramidWJX3078WA 12ms8756kbC++14955b2024-08-20 16:47:472024-08-20 16:47:52

Judging History

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

  • [2024-08-20 16:47:52]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:8756kb
  • [2024-08-20 16:47:47]
  • 提交

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'