QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#630755 | #8046. Rock-Paper-Scissors Pyramid | asaltfish | RE | 0ms | 3556kb | C++14 | 940b | 2024-10-11 20:17:05 | 2024-10-11 20:17:13 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#define ll long long
#define endl "\n"
using namespace std;
ll t,n,a[200005];
string s;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
map<char,int>ch;
ch['S']=0,ch['P']=2,ch['R']=1;
cin>>t;
while(t--)
{
cin>>s;
ll maxn=0;
s=' '+s;
char ans=s[1];
a[1]=0;
for(int i=2;i<s.length();i++)
{
if((ch[s[i-1]]+1)%3==ch[s[i]])
{
a[i]=a[i-1]+1;
}
else if(s[i]==s[i-1])
{
a[i]=a[i-1];
}
else
{
a[i]=a[i-1]-1;
}
if(a[i]>maxn)
{
maxn=a[i];
ans=s[i];
}
}
cout<<ans<<endl;
}
}
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
Runtime Error
input:
1 RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...