QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#628284#8046. Rock-Paper-Scissors Pyramidlonelywolf#WA 8ms4232kbC++20641b2024-10-10 19:28:022024-10-10 19:28:02

Judging History

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

  • [2024-10-10 19:28:02]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:4232kb
  • [2024-10-10 19:28:02]
  • 提交

answer

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

#define int long long  

void solve() {
	string s;
	cin >> s;

	int n = s.size();

	auto win = [&](char a, char b) {
		if (a == 'R') {
			return b == 'S';
		} else if (a == 'P') {
			return b == 'R';
		} else {
			return b == 'P';
		}
		assert(false);
	};

	int ans = 0;
	for (int i = 1; i < s.size(); i++) {
		if (win(s[i], s[i - 1])) {
			ans = i;
		}
	}

	cout << s[ans] << "\n";
}

signed main() {  
    ios::sync_with_stdio(false);
    cin.tie(nullptr);  

    int t;
    cin >> t;
    while (t--) {
    	solve();
    }

    return 0;
}  
  

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 8ms
memory: 4232kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

P

result:

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