QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#690179#8046. Rock-Paper-Scissors PyramidhhdhhWA 18ms5856kbC++231.9kb2024-10-30 20:44:112024-10-30 20:44:11

Judging History

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

  • [2024-10-30 20:44:11]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:5856kb
  • [2024-10-30 20:44:11]
  • 提交

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 num;
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]);
        if(ve.size()>1&&ve[ve.size()-2]==ve.back())
            ve.pop_back();
    }
    int l=0,r=ve.size()-1;
    while(1)
    {
        int p=1;
        if(r-l+1>1)
        {
            if(op(ve[r-1],ve[r])>=0)
                r--,p=0;
            else if(op(ve[l+1],ve[l])>=0)
                l++,p=0;
        }
        if(r-l+1>2)
        {
            if(ve[r-2]==ve[r]&&op(ve[r],ve[r-1])>0)
            {
                r-=2;
                p=0;
            }
            else if(ve[l+2]==ve[l]&&op(ve[l],ve[l+1])>0)
            {
                l+=2;
                p=0;
            }
        }
        if(p)
            break;

    }
    if(num==1)
    {
        rep(i,l,r)
            cout<<ve[i];
    }

    cout<<ve[l]<<endl;

}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("test.in","r",stdin);
    freopen("test.out","w",stdout);
#endif
    LL t=1;
    cin>>t;
    num=t;
    while(t--)
    {
        slove();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 18ms
memory: 5856kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

PRSRSRPSPRPRSRSRPRSPSRSPRPRSRPSRPRPSRPRSRPSRPSRSPRPRSPRSRPRPSRPSRSRPRPRPRPRSRPSRPSRSRSRSPSRPRPSPSRSPSPSRPRPRSRSPSPRPRSRPSRPSPRPSPRSRSRSRSPSRSPRPRSPSRSPRSPRSPSPRPRPRPRPSRSPRSRPRSRPSRPRSPSPSPSPSPSPRPRSPRSRSRPRPSRSPSPRSPRSPSPRSRPSPRPSPRPSPRPSRPRSPRSRSPRPSRSPRPRPRSPRPRPSPSPSRPRSRPRPRPSRSRPRPRPSRPRPSRSPS...

result:

wrong answer 1st lines differ - expected: 'R', found: 'PRSRSRPSPRPRSRSRPRSPSRSPRPRSRP...PSRSRSRPSRSPRPRPRPSRPRSPSRPSRPP'