QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#630755#8046. Rock-Paper-Scissors PyramidasaltfishRE 0ms3556kbC++14940b2024-10-11 20:17:052024-10-11 20:17:13

Judging History

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

  • [2024-10-11 20:17:13]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3556kb
  • [2024-10-11 20:17:05]
  • 提交

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...

output:


result: