Submission #1087392

# Submission time Handle Problem Language Result Execution time Memory
1087392 2024-09-12T15:26:33 Z m5588ohammed RPS string (innopolis2021_final_C) C++14
37 / 100
65 ms 37092 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];
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 build1(){
    ers();
    for(int i=1;i<=n;i++){
        if(s[i-1]=='s') SP[i]++;
        if(s[i-1]=='p') PP[i]++;
        if(s[i-1]=='r') 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]=='s') SS[i]++;
        if(s[i-1]=='p') PS[i]++;
        if(s[i-1]=='r') 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]=='s'){
            if(d==1) type1(i);
            else type2(i);
        }
    }
    return;
}
void build2(){
    ers();
    for(int i=1;i<=n;i++){
        if(s[i-1]=='p') SP[i]++;
        if(s[i-1]=='r') PP[i]++;
        if(s[i-1]=='s') 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]=='p') SS[i]++;
        if(s[i-1]=='r') PS[i]++;
        if(s[i-1]=='s') 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]=='p'){
            if(d==1) type1(i);
            else type2(i);
        }
    }
    return;
}
void build3(){
    ers();
    for(int i=1;i<=n;i++){
        if(s[i-1]=='r') SP[i]++;
        if(s[i-1]=='s') PP[i]++;
        if(s[i-1]=='p') 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]=='r') SS[i]++;
        if(s[i-1]=='s') PS[i]++;
        if(s[i-1]=='p') 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]=='r'){
            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();
        build1();
        build2();
        build3();
        for(int i=1;i<=n;i++) cout<<ans[i];
        cout<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 464 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 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 464 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 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 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 1 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 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 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 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 464 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 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 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 1 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 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 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 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 468 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 860 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 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 604 KB Output is correct
47 Correct 1 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 464 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 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 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 1 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 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 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 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 468 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 860 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 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 604 KB Output is correct
47 Correct 1 ms 860 KB Output is correct
48 Correct 40 ms 1532 KB Output is correct
49 Correct 41 ms 1620 KB Output is correct
50 Correct 47 ms 1484 KB Output is correct
51 Correct 39 ms 1616 KB Output is correct
52 Correct 43 ms 1460 KB Output is correct
53 Correct 60 ms 1616 KB Output is correct
54 Correct 43 ms 1564 KB Output is correct
55 Correct 44 ms 1548 KB Output is correct
56 Correct 40 ms 1624 KB Output is correct
57 Correct 60 ms 1540 KB Output is correct
58 Correct 40 ms 1556 KB Output is correct
59 Correct 40 ms 1628 KB Output is correct
60 Correct 43 ms 1616 KB Output is correct
61 Correct 40 ms 1628 KB Output is correct
62 Correct 45 ms 1624 KB Output is correct
63 Correct 35 ms 8612 KB Output is correct
64 Correct 48 ms 37032 KB Output is correct
65 Correct 33 ms 8540 KB Output is correct
66 Correct 48 ms 37092 KB Output is correct
67 Correct 65 ms 8568 KB Output is correct
68 Correct 43 ms 5100 KB Output is correct
69 Correct 42 ms 1672 KB Output is correct
70 Correct 42 ms 1368 KB Output is correct
71 Correct 45 ms 8664 KB Output is correct
72 Correct 43 ms 4944 KB Output is correct
73 Correct 61 ms 1616 KB Output is correct
74 Correct 42 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 464 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 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 464 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 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 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 1 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 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 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 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Incorrect 1 ms 348 KB Output isn't correct
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 464 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 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 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 1 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 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 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 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 468 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 860 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 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 604 KB Output is correct
47 Correct 1 ms 860 KB Output is correct
48 Incorrect 1 ms 348 KB Output isn't correct
49 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 464 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 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 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 1 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 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 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 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 468 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 860 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 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 604 KB Output is correct
47 Correct 1 ms 860 KB Output is correct
48 Correct 40 ms 1532 KB Output is correct
49 Correct 41 ms 1620 KB Output is correct
50 Correct 47 ms 1484 KB Output is correct
51 Correct 39 ms 1616 KB Output is correct
52 Correct 43 ms 1460 KB Output is correct
53 Correct 60 ms 1616 KB Output is correct
54 Correct 43 ms 1564 KB Output is correct
55 Correct 44 ms 1548 KB Output is correct
56 Correct 40 ms 1624 KB Output is correct
57 Correct 60 ms 1540 KB Output is correct
58 Correct 40 ms 1556 KB Output is correct
59 Correct 40 ms 1628 KB Output is correct
60 Correct 43 ms 1616 KB Output is correct
61 Correct 40 ms 1628 KB Output is correct
62 Correct 45 ms 1624 KB Output is correct
63 Correct 35 ms 8612 KB Output is correct
64 Correct 48 ms 37032 KB Output is correct
65 Correct 33 ms 8540 KB Output is correct
66 Correct 48 ms 37092 KB Output is correct
67 Correct 65 ms 8568 KB Output is correct
68 Correct 43 ms 5100 KB Output is correct
69 Correct 42 ms 1672 KB Output is correct
70 Correct 42 ms 1368 KB Output is correct
71 Correct 45 ms 8664 KB Output is correct
72 Correct 43 ms 4944 KB Output is correct
73 Correct 61 ms 1616 KB Output is correct
74 Correct 42 ms 1364 KB Output is correct
75 Incorrect 1 ms 348 KB Output isn't correct
76 Halted 0 ms 0 KB -