QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#666458 | #8046. Rock-Paper-Scissors Pyramid | yueyuey | WA | 14ms | 5840kb | C++23 | 2.8kb | 2024-10-22 18:34:55 | 2024-10-22 18:34:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define int long long
#define lowbit(x) (x&(-x))
#define pll pair<int,int>
int dx[] = {-1,1,0,0,-1,-1,1,1};
int dy[] = {0,0,-1,1,-1,1,-1,1};
const int N = 2e6+10;
const int mod = 998244353;
const ld eps = 1e-6;
void solve(){
string s; cin>>s;
string t = "";
char l = '1';
for(int i=0;i<s.size();i++){
if(s[i]!=l) t += s[i];
l = s[i];
}
if(t.length()==1){
cout<<t<<"\n";
return ;
}
int k = 100;
while(k--){
l = '1'; s = " " + t; t = "";
int n = s.length()-1;
bool f = 0;
for(int i=2;i<=n;i++){
if(i>=2&&i<=n-1){
if(s[i]=='P'&&s[i-1]=='S'&&s[i+1]=='S'||s[i]=='S'&&s[i-1]=='R'&&s[i+1]=='R'||s[i]=='R'&&s[i-1]=='P'&&s[i+1]=='P'){
f = 1;
}else if(s[i]=='P'&&s[i-1]=='R'&&s[i+1]=='R'||s[i]=='S'&&s[i-1]=='P'&&s[i+1]=='P'||s[i]=='R'&&s[i-1]=='S'&&s[i+1]=='S'){
f = 1;
}
}
char pp;
if(s[i]=='R'){
if(s[i-1]=='R'){
pp = 'R';
}else if(s[i-1]=='S'){
pp = 'R';
}else{
pp = 'P';
}
}else if(s[i]=='S'){
if(s[i-1]=='R'){
pp = 'R';
}else if(s[i-1]=='S'){
pp = 'S';
}else{
pp = 'S';
}
}else{
if(s[i-1]=='R'){
pp = 'P';
}else if(s[i-1]=='S'){
pp = 'S';
}else{
pp = 'P';
}
}
if(l!=pp){
t += pp;
l = pp;
}
}
// cout<<s<<"\n";
// cout<<t<<" "<<f<<"\n\n";
if(t.length()==1){
cout<<t<<"\n";
return;
}
n = t.length();
if(f==0){
if(t[0]=='P'&&t[1]=='R'||t[0]=='R'&&t[1]=='S'||t[0]=='S'&&t[1]=='P'){
cout<<t[0]<<"\n";
return ;
}else if(t[n-1]=='P'&&t[n-2]=='R'||t[n-1]=='P'&&t[n-2]=='R'||t[n-1]=='P'&&t[n-2]=='R'){
cout<<t[n-1]<<"\n";
return ;
}else{
cout<<t[n-1]<<"\n";
return ;
}
}
}
cout<<"S"<<"\n";
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int T = 1;
cin>>T;
while(T--){
solve();
}
return 0;
}
/*
/\_/\
(= ._.)
/ > \>
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
2 SPR SPSRRP
output:
S P
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 14ms
memory: 5840kb
input:
1 RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...
output:
S
result:
wrong answer 1st lines differ - expected: 'R', found: 'S'