QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#624123#8046. Rock-Paper-Scissors PyramidDukerkiWA 55ms5184kbC++201.8kb2024-10-09 15:00:522024-10-09 15:00:53

Judging History

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

  • [2024-10-09 15:00:53]
  • 评测
  • 测评结果:WA
  • 用时:55ms
  • 内存:5184kb
  • [2024-10-09 15:00:52]
  • 提交

answer

#include <iostream>
#include <list>
using namespace std;
int cnt = 0;
void EachT()
{
    cnt++;
    string str;
    int n;
    cin >> str;
    if(cnt == 471){
        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;
    while (t--)
    {
        EachT();
    }
}

詳細信息

Test #1:

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

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

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

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

R

result:

ok single line: 'R'

Test #3:

score: 0
Accepted
time: 35ms
memory: 5140kb

input:

1
PPPPPSPPPRPPPPRRPSRPPRSSRPPPPPPRPPPPRPPSPPPPPPPRPPRRPPRPPSPPPPRRPSPRSPPPPPPRRRPRPRPPPPPPRPPPPPPPSPPPPPPPPRPPPPSPPRPPPPPSPPRPPPSRPPPPRPPRPPRPPPSPPPPPPPRPPRRPPSPRPRPPPPPRPPPPPPPRPRRRSPPPPPSPSPSRPRPSPSPPPPPRSPPPPPRPPPRPPPPPPSRRRPPPPRPSPPSRPPRPPRPPPRRSPPPRRRPPRPPPPPRPPPSPRPPRPPPRPSPPPRPPPPPRRPPSPRPRPR...

output:

P

result:

ok single line: 'P'

Test #4:

score: -100
Wrong Answer
time: 48ms
memory: 3612kb

input:

500
SSSPSSSPRPSPPPPRRPSPSRSPSPPSRPPRRRSRRSPRPRRRRPSSPPRRSPPPSRRSPSPRRSSPPSRPRPPSSPSSRSSSRRSSPSSRSRRPSPSRSSRSRRPRRRPSSPPPSRPSSPPSSPSSPPRRPPRSPSRSRPRRSSRSSRPRRPRSRRPPRRPPRRRRRRRSRSSRPPSRRRPRRPSRPPPPSRSSPPPPSPPPRPPPPPRSRPPRSRPRRPPPRSRRRSSPRSSPPSRRPPPSRPSPSPRSRPRRPSSRPPRRSPSPPPSPPRRPPPRSRSSSRSPRRPSRSRSP...

output:

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

result:

wrong answer 471st lines differ - expected: 'R', found: 'RRPRRSPPPRSRRPPRSSPPPPRRRRPSPS...SPPRRPRRSPSRRRPSRPRPPRSPRSRSSPS'