답안 #1087419

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087419 2024-09-12T16:22:58 Z m5588ohammed RPS string (innopolis2021_final_C) C++14
37 / 100
48 ms 37252 KB
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define mod 998244353
int PP[500002],RP[500002],SP[500002],ans[500002],L[500002],R[500002];
int PS[500002],RS[500002],SS[500002];
char P1,S1,R1;
string s;   
int n,d;
void ers(){
    for(int i=1;i<=n+1;i++) PP[i]=RP[i]=SP[i]=PS[i]=RS[i]=SS[i]=L[i]=R[i]=0;
    return; 
}
void ERS(){
    for(int i=1;i<=n+1;i++) PP[i]=RP[i]=SP[i]=L[i]=R[i]=ans[i]=0;
    return; 
}
void type1(int k){
    if(RP[k]>0&&PP[k]>0){
        if(RS[k]>0&&PS[k]>0) ans[k]=1;
        if(RS[k]==0) ans[k]=1;
    }
    if(RP[k]==0){
        if(RS[k]>0&&PS[k]>0) ans[k]=1;
        if(RS[k]==0) ans[k]=1;
    }
    return;
}
void type2(int k){

}
void build(){
    ers();
    for(int i=1;i<=n;i++){
        if(s[i-1]==S1) SP[i]++;
        if(s[i-1]==P1) PP[i]++;
        if(s[i-1]==R1) RP[i]++;
        RP[i]+=RP[i-1];
        SP[i]+=SP[i-1];
        PP[i]+=PP[i-1];
    }
    for(int i=n;i>=1;i--){
        if(s[i-1]==S1) SS[i]++;
        if(s[i-1]==P1) PS[i]++;
        if(s[i-1]==R1) RS[i]++;
        RS[i]+=RS[i+1];
        SS[i]+=SS[i+1];
        PS[i]+=PS[i+1];
    }
    for(int i=1;i<=n;i++){
        if(s[i-1]==S1){
            if(d==1) type1(i);
            else type2(i);
        }
    }
    return;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        cin>>d>>s; 
        n=s.size();
        ERS();
        S1='s',P1='p',R1='r';
        build();
        S1='p',P1='r',R1='s';
        build();
        S1='r',P1='s',R1='p';
        build();
        for(int i=1;i<=n;i++) cout<<ans[i];
        cout<<endl;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 472 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 1 ms 860 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 1 ms 872 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 1 ms 860 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 468 KB Output is correct
47 Correct 1 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 472 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 1 ms 860 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 1 ms 872 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 1 ms 860 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 468 KB Output is correct
47 Correct 1 ms 860 KB Output is correct
48 Correct 37 ms 1512 KB Output is correct
49 Correct 37 ms 1616 KB Output is correct
50 Correct 37 ms 1616 KB Output is correct
51 Correct 40 ms 1580 KB Output is correct
52 Correct 37 ms 1616 KB Output is correct
53 Correct 40 ms 1620 KB Output is correct
54 Correct 38 ms 1628 KB Output is correct
55 Correct 37 ms 1472 KB Output is correct
56 Correct 39 ms 1496 KB Output is correct
57 Correct 38 ms 1572 KB Output is correct
58 Correct 40 ms 1876 KB Output is correct
59 Correct 44 ms 1580 KB Output is correct
60 Correct 39 ms 1616 KB Output is correct
61 Correct 37 ms 1608 KB Output is correct
62 Correct 37 ms 1620 KB Output is correct
63 Correct 36 ms 8536 KB Output is correct
64 Correct 48 ms 37120 KB Output is correct
65 Correct 34 ms 8756 KB Output is correct
66 Correct 48 ms 37252 KB Output is correct
67 Correct 47 ms 8584 KB Output is correct
68 Correct 44 ms 4948 KB Output is correct
69 Correct 42 ms 1628 KB Output is correct
70 Correct 43 ms 1372 KB Output is correct
71 Correct 47 ms 8712 KB Output is correct
72 Correct 44 ms 4952 KB Output is correct
73 Correct 42 ms 1628 KB Output is correct
74 Correct 42 ms 1348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Incorrect 0 ms 348 KB Output isn't correct
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 472 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 1 ms 860 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 1 ms 872 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 1 ms 860 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 468 KB Output is correct
47 Correct 1 ms 860 KB Output is correct
48 Incorrect 0 ms 348 KB Output isn't correct
49 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 472 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 1 ms 860 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 1 ms 872 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 1 ms 860 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 468 KB Output is correct
47 Correct 1 ms 860 KB Output is correct
48 Correct 37 ms 1512 KB Output is correct
49 Correct 37 ms 1616 KB Output is correct
50 Correct 37 ms 1616 KB Output is correct
51 Correct 40 ms 1580 KB Output is correct
52 Correct 37 ms 1616 KB Output is correct
53 Correct 40 ms 1620 KB Output is correct
54 Correct 38 ms 1628 KB Output is correct
55 Correct 37 ms 1472 KB Output is correct
56 Correct 39 ms 1496 KB Output is correct
57 Correct 38 ms 1572 KB Output is correct
58 Correct 40 ms 1876 KB Output is correct
59 Correct 44 ms 1580 KB Output is correct
60 Correct 39 ms 1616 KB Output is correct
61 Correct 37 ms 1608 KB Output is correct
62 Correct 37 ms 1620 KB Output is correct
63 Correct 36 ms 8536 KB Output is correct
64 Correct 48 ms 37120 KB Output is correct
65 Correct 34 ms 8756 KB Output is correct
66 Correct 48 ms 37252 KB Output is correct
67 Correct 47 ms 8584 KB Output is correct
68 Correct 44 ms 4948 KB Output is correct
69 Correct 42 ms 1628 KB Output is correct
70 Correct 43 ms 1372 KB Output is correct
71 Correct 47 ms 8712 KB Output is correct
72 Correct 44 ms 4952 KB Output is correct
73 Correct 42 ms 1628 KB Output is correct
74 Correct 42 ms 1348 KB Output is correct
75 Incorrect 0 ms 348 KB Output isn't correct
76 Halted 0 ms 0 KB -