QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624147#8046. Rock-Paper-Scissors PyramidDukerkiWA 99ms5256kbC++201.9kb2024-10-09 15:06:002024-10-09 15:06:02

Judging History

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

  • [2024-10-09 15:06:02]
  • 评测
  • 测评结果:WA
  • 用时:99ms
  • 内存:5256kb
  • [2024-10-09 15:06:00]
  • 提交

answer

#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
int cnt = 0,total = 0;
void EachT()
{
    cnt++;
    string str;
    int n;
    cin >> str;
    int cut = str.end() - unique(str.begin(), str.end());
    while (cut--)
    {
        str.pop_back();
    }
    
    //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: 3600kb

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 49ms
memory: 5256kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

R

result:

ok single line: 'R'

Test #3:

score: 0
Accepted
time: 32ms
memory: 5116kb

input:

1
PPPPPSPPPRPPPPRRPSRPPRSSRPPPPPPRPPPPRPPSPPPPPPPRPPRRPPRPPSPPPPRRPSPRSPPPPPPRRRPRPRPPPPPPRPPPPPPPSPPPPPPPPRPPPPSPPRPPPPPSPPRPPPSRPPPPRPPRPPRPPPSPPPPPPPRPPRRPPSPRPRPPPPPRPPPPPPPRPRRRSPPPPPSPSPSRPRPSPSPPPPPRSPPPPPRPPPRPPPPPPSRRRPPPPRPSPPSRPPRPPRPPPRRSPPPRRRPPRPPPPPRPPPSPRPPRPPPRPSPPPRPPPPPRRPPSPRPRPR...

output:

P

result:

ok single line: 'P'

Test #4:

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

input:

500
SSSPSSSPRPSPPPPRRPSPSRSPSPPSRPPRRRSRRSPRPRRRRPSSPPRRSPPPSRRSPSPRRSSPPSRPRPPSSPSSRSSSRRSSPSSRSRRPSPSRSSRSRRPRRRPSSPPPSRPSSPPSSPSSPPRRPPRSPSRSRPRRSSRSSRPRRPRSRRPPRRPPRRRRRRRSRSSRPPSRRRPRR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PRRRPPRSRRRRRRPRR...

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: 25ms
memory: 3608kb

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: 99ms
memory: 3832kb

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

result:

wrong answer 115th lines differ - expected: 'R', found: ''