QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623952 | #8046. Rock-Paper-Scissors Pyramid | Dukerki | WA | 20ms | 5196kb | C++20 | 2.0kb | 2024-10-09 14:27:43 | 2024-10-09 14:27:46 |
Judging History
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
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'