QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#690007 | #8046. Rock-Paper-Scissors Pyramid | hhdhh | WA | 0ms | 3512kb | C++23 | 2.1kb | 2024-10-30 19:43:08 | 2024-10-30 19:43:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(LL i=(a);i<=(b);i++)
#define rept(i,a,ne) for(LL i=(a);i!=-1;i=ne[i])
#define per(i,a,b) for(LL i=(a);i>=(b);i--)
#define endl '\n'
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL,LL> PII;
#define debug(x) cout<<#x<<" :"<<x<<endl;
ULL P=131;
const int N=4e5+10;
int a[N];
bool bo[N];
int op(char a,char b)
{
if(a==b)
return 0;
if(a=='R')
{
if(b=='S')
return 1;
else
return -1;
}
if(a=='S')
{
if(b=='R')
return -1;
else
return 1;
}
if(a=='P')
{
if(b=='R')
return 1;
else
return -1;
}
}
void slove()
{
string s;
cin>>s;
int n=s.size();
s='0'+s;
vector<char>ve;
rep(i,1,n)
{
ve.push_back(s[i]);
while(1)
{
int p=0;
if(ve.size()==2&&op(ve[0],ve[1])>0)
ve.pop_back(),p=1;
if(ve.size()>1&&ve[ve.size()-2]==ve[ve.size()-1])
ve.pop_back(),p=1;
if (ve.size()>2&&ve[ve.size()-3]==ve[ve.size()-1])
{
char la=ve.back();
ve.pop_back();
char mid=ve.back();
ve.pop_back();
ve.pop_back();
if(op(mid,la)>=0)
ve.push_back(mid);
else
ve.push_back(la);
p=1;
}
if(p==0)break;
}
}
if(ve.size()>1)
{
rep(i,0,ve.size()-2)
while(ve[i]==ve[i+1]);
if(op(ve[0],ve[1])>0)
cout<<ve.front()<<endl;
else
cout<<ve.back()<<endl;
}
else
cout<<ve.back()<<endl;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("test.in","r",stdin);
freopen("test.out","w",stdout);
#endif
LL t=1;
cin>>t;
while(t--)
{
slove();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3512kb
input:
2 SPR SPSRRP
output:
R P
result:
wrong answer 1st lines differ - expected: 'S', found: 'R'