QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#597898#8046. Rock-Paper-Scissors PyramidlongyinTL 0ms3636kbC++171.2kb2024-09-28 19:22:522024-09-28 19:22:54

Judging History

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

  • [2024-09-28 19:22:54]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3636kb
  • [2024-09-28 19:22:52]
  • 提交

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];
inline char find(char c) {
  if(c == 'S') return 'R';
  if(c == 'P') return 'S';
  if(c == 'R') return 'P';
}
char q[maxn];
signed main() {
  T = qread();
  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 && find(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: 3636kb

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: -100
Time Limit Exceeded

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:


result: