QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#617816#8046. Rock-Paper-Scissors PyramidtomatossWA 17ms6688kbC++172.0kb2024-10-06 17:14:222024-10-06 17:14:23

Judging History

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

  • [2024-10-06 17:14:23]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:6688kb
  • [2024-10-06 17:14:22]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[1010], b[1010];
int n;
double t = 0.3331321335578;
double ct = 0;
void solve() {
	ct += t;
	cout << ct << '\n';
}
void find(string st) {
	string s = "";
	for (auto u : st) {
		//cout<<s.back()<<" "<<u<<'\n';
		if (u != s.back())s += u;
	}
	int l = 0, r = 0;
	for (int i = 2; i < s.size(); i++) {
		if (s.substr(i - 2, 3) == "RSP") {
			l = 1;
			break;
		}
		if (s.substr(i - 2, 3) == "PRS") {
			l = 2;
			break;
		}
		if (s.substr(i - 2, 3) == "SPR") {
			l = 3;
			break;
		}
	}
	reverse(s.begin(),s.end());
	for (int i = 2; i < s.size(); i++) {
		//cout<<s.substr(i - 2, 3)<<'\n';
		if (s.substr(i - 2, 3) == "RSP") {
			r = 1;
			break;
		}
		if (s.substr(i - 2, 3) == "PRS") {
			r = 2;
			break;
		}
		if (s.substr(i - 2, 3) == "SPR") {
			r = 3;
			break;
		}
	}
	//cout<<l<<" "<<r<<'\n';
	if(l == 0&&r == 0){
		auto win = [&](char &x, char y) {
	        if (x == 'S' && y == 'R') x = 'R';
	        else if (x == 'R' && y == 'P') x = 'P';
	        else if (x == 'P' && y == 'S') x = 'S';
	    };
	    win(s[0],s[1]);
	    cout<<s[0]<<'\n';
	    return;
	}
	if(r == 0){
		if (l == 1)cout << 'R' << '\n';
		else if (l == 2)cout << 'P' << '\n';
		else cout << 'S' << '\n';
		return;
	}
	if(l == 0){
		if (r == 1)cout << 'R' << '\n';
		else if (r == 2)cout << 'P' << '\n';
		else cout << 'S' << '\n';
		return;
	}
	if (l == r) {
		if (l == 1)cout << 'R' << '\n';
		else if (l == 2)cout << 'P' << '\n';
		else cout << 'S' << '\n';
		return;
	}
		if (l == 1) {
			if (r == 2) {
				cout << "P" << '\n';
			}
			else {
				cout << "R" << '\n';
			}
		}
		else if (l == 2) {
			if (r == 1) {
				cout << "P" << '\n';
			}
			else {
				cout << "S" << '\n';
			}
		}
		else {
			if (r == 1) {
				cout << "R" << '\n';
			}
			else {
				cout << "S" << '\n';
			}
		}

}
signed main() {
	int t; cin >> t;
	while (t--) {
		string s;
		cin >> s;
		find(s);
	}
}

詳細信息

Test #1:

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

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 17ms
memory: 6688kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

P

result:

wrong answer 1st lines differ - expected: 'R', found: 'P'