QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#623952#8046. Rock-Paper-Scissors PyramidDukerkiWA 20ms5196kbC++202.0kb2024-10-09 14:27:432024-10-09 14:27:46

Judging History

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

  • [2024-10-09 14:27:46]
  • 评测
  • 测评结果:WA
  • 用时:20ms
  • 内存:5196kb
  • [2024-10-09 14:27:43]
  • 提交

answer

#include <iostream>
#include <list>
using namespace std;
void EachT()
{
    string str;
    int n;
    cin >> str;
    string s;
    char T;
    for (int i = 0; i < str.size(); i++)
    {
        T = str[i];
        if (s.size() == 0 || s.back() != T)
        {
            if (s.size() >= 2)
            {
                if (s[s.size() - 2] == T)
                {
                    if (T == 'S' && s.back() == 'P')
                    {
                        s.pop_back();
                    }
                    else if (T == 'S' && s.back() == 'R')
                    {
                        s.pop_back();
                        s.back() = 'R';
                    }
                    else if (T == 'P' && s.back() == 'R')
                    {
                        s.pop_back();
                    }
                    else if (T == 'P' && s.back() == 'S')
                    {
                        s.pop_back();
                        s.back() = 'S';
                    }
                    else if (T == 'R' && s.back() == 'S')
                    {
                        s.pop_back();
                    }
                    else if (T == 'R' && s.back() == 'P')
                    {
                        s.pop_back();
                        s.back() = 'P';
                    }
                }
                else
                {
                    s.push_back(T);
                }
            }
            else
            {
                s.push_back(T);
            }
        }
    }
    //cout << s << endl;
    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: 3536kb

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 20ms
memory: 5196kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

P

result:

wrong answer 1st lines differ - expected: 'R', found: 'P'