QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#597918 | #8046. Rock-Paper-Scissors Pyramid | longyin | TL | 0ms | 3620kb | C++17 | 1.2kb | 2024-09-28 19:27:04 | 2024-09-28 19:27:06 |
Judging History
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;
}
详细
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...