QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#597918#8046. Rock-Paper-Scissors PyramidlongyinTL 0ms3620kbC++171.2kb2024-09-28 19:27:042024-09-28 19:27:06

Judging History

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

  • [2024-09-28 19:27:06]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3620kb
  • [2024-09-28 19:27:04]
  • 提交

answer

#include <bits/stdc++.h>
#define maxn 1000007
#define int long long
#define dl long double
#define mod 1000000007
using namespace std;
int n, m;
inline int pls(int a, int b) {int m = a + b; return m < mod ? m : m - mod;}
inline int dec(int a, int b) {int m = a - b; return m < 0 ? m + mod : m;}
inline int mul(int a, int b) {return 1ll * a * b % mod;}
inline int fpow(int a, int b) {
  int ans = 1;
  for(; b; b >>= 1,a = mul(a, a)) if(b & 1) ans = mul(ans, a);
  return ans;
}
inline int inv(int a) {return fpow(a, mod - 2);}
inline int dvi(int a, int b) {return mul(a, inv(b));};
inline int qread() {
  char c = getchar(); int num = 0, f = 1;
  for(; !isdigit(c); c=getchar()) if(c == '-') f = -1;
  for(; isdigit(c); c=getchar()) num = num * 10 + c - '0';
  return num * f;
}
int T;
char s[maxn];
map<char, char> fd;
char q[maxn];
signed main() {
  T = qread();
  fd['S'] = 'R';
  fd['P'] = 'S';
  fd['R'] = 'P';
  while(T--) {
    int top = 0;
//    stack<char> q;
    scanf("%s", s + 1);
    q[top++] = s[1]; 
    for(int i = 2; i <= strlen(s + 1); ++i) {
      while(top && fd[q[top - 1]] == s[i]) --top;
      q[top++] = s[i]; 
    }
    cout << q[0]<< '\n';
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: -100
Time Limit Exceeded

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:


result: