QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624131#8046. Rock-Paper-Scissors PyramidDukerkiWA 56ms5360kbC++201.8kb2024-10-09 15:01:592024-10-09 15:02:04

Judging History

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

  • [2024-10-09 15:02:04]
  • 评测
  • 测评结果:WA
  • 用时:56ms
  • 内存:5360kb
  • [2024-10-09 15:01:59]
  • 提交

answer

#include <iostream>
#include <list>
using namespace std;
int cnt = 0,total = 0;
void EachT()
{
    cnt++;
    string str;
    int n;
    cin >> str;
    if(cnt == 471 && total == 130000){
        cout << str << endl;
    }
    string s;
    char T;
    s = str;
    str.clear();
    for (int i = 1; i < s.size(); i++)
    {
        if ((s[i - 1] == 'S' && s[i] == 'P') || (s[i - 1] == 'P' && s[i] == 'R') || (s[i - 1] == 'R' && s[i] == 'S'))
        {
            str.push_back(s[i - 1]);
        }
        else
        {
            str.push_back(s[i]);
        }
    }
    s.clear();
    while (s.size() != 1)
    {
        s.clear();
        bool flag = true;
        for (int i = 0; i < str.size(); i++)
        {
            T = str[i];
            if (s.size() == 0 || s.back() != T)
            {
                s.push_back(T);
            }
            else
            {
                flag = false;
            }
        }
        if (flag)
        {
            break;
        }
        str.clear();
        for (int i = 1; i < s.size(); i++)
        {
            if ((s[i - 1] == 'S' && s[i] == 'P') || (s[i - 1] == 'P' && s[i] == 'R') || (s[i - 1] == 'R' && s[i] == 'S'))
            {
                str.push_back(s[i - 1]);
            }
            else
            {
                str.push_back(s[i]);
            }
        }
    }
    if (s.size() == 1)
    {
        cout << s[0] << endl;
    }
    else
    {
        if ((s[0] == 'S' && s[1] == 'P') || (s[0] == 'P' && s[1] == 'R') || (s[0] == 'R' && s[1] == 'S'))
        {
            cout << s[0] << endl;
        }
        else
        {
            cout << s[s.size() - 1] << endl;
        }
    }
}
int main()
{
    int t;
    cin >> t;
    total = t;
    while (t--)
    {
        EachT();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 55ms
memory: 5360kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

R

result:

ok single line: 'R'

Test #3:

score: 0
Accepted
time: 31ms
memory: 5276kb

input:

1
PPPPPSPPPRPPPPRRPSRPPRSSRPPPPPPRPPPPRPPSPPPPPPPRPPRRPPRPPSPPPPRRPSPRSPPPPPPRRRPRPRPPPPPPRPPPPPPPSPPPPPPPPRPPPPSPPRPPPPPSPPRPPPSRPPPPRPPRPPRPPPSPPPPPPPRPPRRPPSPRPRPPPPPRPPPPPPPRPRRRSPPPPPSPSPSRPRPSPSPPPPPRSPPPPPRPPPRPPPPPPSRRRPPPPRPSPPSRPPRPPRPPPRRSPPPRRRPPRPPPPPRPPPSPRPPRPPPRPSPPPRPPPPPRRPPSPRPRPR...

output:

P

result:

ok single line: 'P'

Test #4:

score: 0
Accepted
time: 44ms
memory: 3768kb

input:

500
SSSPSSSPRPSPPPPRRPSPSRSPSPPSRPPRRRSRRSPRPRRRRPSSPPRRSPPPSRRSPSPRRSSPPSRPRPPSSPSSRSSSRRSSPSSRSRRPSPSRSSRSRRPRRRPSSPPPSRPSSPPSSPSSPPRRPPRSPSRSRPRRSSRSSRPRRPRSRRPPRRPPRRRRRRRSRSSRPPSRRRPRRPSRPPPPSRSSPPPPSPPPRPPPPPRSRPPRSRPRRPPPR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
R
...

result:

ok 2000 lines

Test #6:

score: 0
Accepted
time: 44ms
memory: 3608kb

input:

500
SRSSSRPPPPPRRPSPSPPPRPPRRRPSRPPRPPSPPSPPPPPSPSRPSRSPPPSPPPRPPRPPPPPPPPSPSSRPSPPPPPPPRSSRPPPRRRPPPPPSRSPPSPRRSSPPPRSPRRRRPPSSSSSRRPRPPPSRPPRPPPRSSPRRRRPSPSSRPPSRRPPPSRPSRPRRPSPSPPSPSPRSSRPPPSRPRPPSPPPPPRPSPRSPPRRSSPSSPPPPPSPRPPSSPRRPSSPPSRPPPRRPPPPPPPSPRSPPPPPSPSPPSRSPRRPRPPPPSRRPPPPSRSPSPRSRPSSP...

output:

S
S
P
R
P
S
S
S
S
P
S
S
R
R
S
P
S
R
S
S
R
S
R
R
S
R
S
S
S
P
R
S
S
P
S
S
R
S
S
S
R
P
R
S
S
P
S
S
S
R
S
P
R
S
S
P
R
P
S
S
P
S
S
P
P
R
P
S
S
P
S
S
S
S
P
S
S
P
S
P
S
S
S
S
S
S
S
R
R
P
R
S
P
S
S
S
R
R
P
S
S
S
S
S
R
P
S
R
S
R
S
S
R
S
P
R
R
S
S
P
R
S
S
R
R
S
R
S
S
P
S
S
R
S
S
R
S
R
S
S
P
S
P
P
R
S
P
S
S
S
...

result:

ok 500 lines

Test #7:

score: 0
Accepted
time: 33ms
memory: 3592kb

input:

500
RPRRRPRPRRRRPRRRPPPRPSPPPRRRRRRPRSPPPRSRPRRRRRPRPRRRRPRPRSRPRPSRRPPPRRRRRRPRRPRSRRPPSRPPSSRPPRSPSPSRRSRRRPRSRPRRPRRPPRSRSPRRPRRRRRRPRRPRPRPRRSRRRRPRPRRRSRRPPRRPRRPPRRSPRPRRRRPPRSRRPRRRRPRPRPRRPRRSRRRPPPRRRPRPRSRRRSRPRRPRRSPRRPRRSSSRSPRRRRRRPPRPRSRRPRPRPRSRRRPRRRPRPPRRRPPPRSRRRRPPRRRPPRSRRRRRRPRR...

output:

P
S
S
R
R
P
P
R
P
P
P
P
S
P
P
P
S
P
P
P
P
P
R
R
S
P
P
P
R
S
S
P
S
P
P
S
S
R
S
P
R
R
P
P
P
P
P
P
S
P
P
S
P
P
P
P
S
P
R
P
P
S
P
P
P
P
P
P
P
P
P
P
S
P
R
S
P
P
P
S
S
P
P
P
S
S
R
P
R
P
P
S
P
S
P
P
S
P
S
P
R
S
R
P
P
R
S
P
P
S
R
R
P
P
P
R
P
S
S
S
P
P
P
P
S
R
P
P
P
P
P
S
S
P
S
P
S
P
P
S
P
R
P
S
S
R
S
P
S
S
...

result:

ok 500 lines

Test #8:

score: 0
Accepted
time: 26ms
memory: 3572kb

input:

500
SRSPSPRSSSSSSRSSSSSPSSSPSSSSSSSSSSSSSSSSSSSSRSSSSSSSRSSRSPSRSSSSSSSSSSSSSSSSSSSRSSSRSSSSSSRRSPSRSSSPSSPPSSSSSSRSSSSSSSSPSRPSSSSSSPSRRSSSPSSSSRPSSSPSPRSSSSSSSPSSSSSSRSSRSSRSSSPSSSSSRSSPSSSSSSSSSSRSRSSSSRPSSSSSSSPSSSSSSSSSPSSRSSSSSSSSSSSSPRSSSSSRSSPSSSSSSSSSSRSSPRPSSSSPSRSSSSSSSSSSPSRSSSSSSRSSSSSS...

output:

R
R
R
R
R
R
R
R
R
S
R
S
R
R
S
R
P
S
R
P
R
R
S
R
R
R
R
S
R
R
P
R
S
S
R
R
S
R
R
R
R
R
S
R
R
S
R
R
R
R
R
R
R
P
P
S
R
R
S
P
R
R
R
R
R
R
R
P
P
R
P
R
P
S
S
R
R
S
R
S
R
R
S
R
S
R
R
R
R
R
S
R
P
R
R
R
R
R
S
R
S
R
R
R
P
S
R
R
R
R
R
P
R
S
P
R
S
R
S
R
S
P
R
R
R
R
P
P
R
S
R
R
R
R
R
P
P
R
R
P
R
R
R
S
R
S
P
R
R
P
...

result:

ok 500 lines

Test #9:

score: -100
Wrong Answer
time: 56ms
memory: 3532kb

input:

130000
RSRPPR
PRR
PRSRPSP
PRSPPRRP
SSRRRPSSRRR
SRS
RPSPPRRRPPSRRPSR
PPRPRR
RRRPSRSP
RRSR
RRPSRPRPPP
RRPRSSSS
PPSSPPRSS
SSSPPRRS
PRRS
PRRRSSPP
RRPPPRPPP
SRSRRR
PPRSRSSRR
SSRSRPRP
RPPSRPRP
PSSPPRS
SPSRPPS
PSSS
RPPPPPRS
PRSSPRRPRP
SPSSRSRPP
RPRPR
RRSP
RPPPPS
PPRPPSPS
SSRPSRS
SSSRPPR
RPPPPRPRS
PRSPRR
SS...

output:

P
P
S
P
R
R
R
P
R
R
P
P
S
S
P
P
P
R
P
P
P
S
S
S
P
P
P
P
R
S
S
R
P
P
P
S
R
S
R
R
P
R
S
S
S
P
P
S
S
P
S
S
P
P
S
P
S
P
P
P
R
S
P
P
R
S
S
R
S
R
S
P
S
R
R
P
P
P
P
R
R
R
S
S
R
S
P
P
S
R
R
R
R
S
S
R
P
R
R
R
R
S
P
S
S
R
S
P
S
S
P
R
R
R
R
P
S
S
P
S
P
R
R
P
S
R
P
R
S
S
P
R
R
P
P
R
P
S
R
S
S
S
S
P
P
S
P
R
S
R
...

result:

wrong answer 471st lines differ - expected: 'S', found: 'PRRPS'