Submission #970024

# Submission time Handle Problem Language Result Execution time Memory
970024 2024-04-26T06:47:33 Z 12345678 Homework (CEOI22_homework) C++17
23 / 100
23 ms 32416 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=1e6+5;

int n, t[nx], sz[nx], mn[nx], mx[nx], p[nx];
string s;

int build(int l, int i)
{
    if (s[l]=='?') return l;
    if (s[l+1]=='i') t[i]=1;
    else t[i]=2;
    int tmp=build(l+4, 2*i);
    l=tmp+2;
    tmp=build(l, 2*i+1);
    return tmp+1; 
}

void solve(int i)
{
    if (t[i]==0) return sz[i]=mn[i]=mx[i]=1, void();
    solve(2*i);
    solve(2*i+1);
    sz[i]=sz[2*i]+sz[2*i+1];
    if (t[i]==1)
    {
        mn[i]=min(mn[2*i], mn[2*i+1]);
        mx[i]=mx[2*i]+mx[2*i+1]-1;
    }
    if (t[i]==2)
    {
        mn[i]=mn[2*i]+mn[2*i+1];
        mx[i]=max(sz[2*i]+mx[2*i+1], mx[2*i]+sz[2*i+1]);
    }
    //cout<<"debug "<<i<<' '<<mn[i]<<' '<<mx[i]<<'\n';
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>s;
    n=s.size();
    build(0, 1);
    solve(1);
    cout<<mx[1]-mn[1]+1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8540 KB Output is correct
2 Correct 1 ms 8536 KB Output is correct
3 Correct 1 ms 8536 KB Output is correct
4 Correct 2 ms 8536 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8652 KB Output is correct
7 Correct 2 ms 8540 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 8540 KB Output is correct
10 Correct 1 ms 8536 KB Output is correct
11 Correct 1 ms 8656 KB Output is correct
12 Correct 2 ms 8776 KB Output is correct
13 Correct 1 ms 8540 KB Output is correct
14 Correct 2 ms 8536 KB Output is correct
15 Correct 2 ms 8540 KB Output is correct
16 Correct 1 ms 8540 KB Output is correct
17 Correct 1 ms 8540 KB Output is correct
18 Correct 1 ms 8540 KB Output is correct
19 Correct 1 ms 8656 KB Output is correct
20 Correct 1 ms 8536 KB Output is correct
21 Correct 2 ms 8536 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 1 ms 8616 KB Output is correct
24 Correct 1 ms 8540 KB Output is correct
25 Correct 1 ms 8540 KB Output is correct
26 Correct 1 ms 8540 KB Output is correct
27 Correct 1 ms 8536 KB Output is correct
28 Correct 1 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8540 KB Output is correct
2 Correct 1 ms 8536 KB Output is correct
3 Correct 1 ms 8536 KB Output is correct
4 Correct 2 ms 8536 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8652 KB Output is correct
7 Correct 2 ms 8540 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 8540 KB Output is correct
10 Correct 1 ms 8536 KB Output is correct
11 Correct 1 ms 8656 KB Output is correct
12 Correct 2 ms 8776 KB Output is correct
13 Correct 1 ms 8540 KB Output is correct
14 Correct 2 ms 8536 KB Output is correct
15 Correct 2 ms 8540 KB Output is correct
16 Correct 1 ms 8540 KB Output is correct
17 Correct 1 ms 8540 KB Output is correct
18 Correct 1 ms 8540 KB Output is correct
19 Correct 1 ms 8656 KB Output is correct
20 Correct 1 ms 8536 KB Output is correct
21 Correct 2 ms 8536 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 1 ms 8616 KB Output is correct
24 Correct 1 ms 8540 KB Output is correct
25 Correct 1 ms 8540 KB Output is correct
26 Correct 1 ms 8540 KB Output is correct
27 Correct 1 ms 8536 KB Output is correct
28 Correct 1 ms 8540 KB Output is correct
29 Correct 1 ms 8536 KB Output is correct
30 Correct 1 ms 8540 KB Output is correct
31 Correct 2 ms 8668 KB Output is correct
32 Correct 2 ms 8540 KB Output is correct
33 Correct 1 ms 8540 KB Output is correct
34 Correct 1 ms 8540 KB Output is correct
35 Correct 1 ms 8540 KB Output is correct
36 Correct 1 ms 8540 KB Output is correct
37 Correct 1 ms 8544 KB Output is correct
38 Correct 1 ms 8672 KB Output is correct
39 Correct 2 ms 8548 KB Output is correct
40 Correct 1 ms 8540 KB Output is correct
41 Correct 2 ms 8540 KB Output is correct
42 Correct 1 ms 8548 KB Output is correct
43 Correct 1 ms 8664 KB Output is correct
44 Correct 2 ms 8536 KB Output is correct
45 Correct 1 ms 8552 KB Output is correct
46 Correct 1 ms 8664 KB Output is correct
47 Correct 1 ms 8540 KB Output is correct
48 Correct 1 ms 8540 KB Output is correct
49 Correct 1 ms 8792 KB Output is correct
50 Correct 2 ms 8552 KB Output is correct
51 Correct 2 ms 8540 KB Output is correct
52 Correct 1 ms 8540 KB Output is correct
53 Correct 1 ms 8540 KB Output is correct
54 Correct 1 ms 8540 KB Output is correct
55 Correct 1 ms 8656 KB Output is correct
56 Correct 2 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 23 ms 32416 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8540 KB Output is correct
2 Correct 1 ms 8536 KB Output is correct
3 Correct 1 ms 8536 KB Output is correct
4 Correct 2 ms 8536 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8652 KB Output is correct
7 Correct 2 ms 8540 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 8540 KB Output is correct
10 Correct 1 ms 8536 KB Output is correct
11 Correct 1 ms 8656 KB Output is correct
12 Correct 2 ms 8776 KB Output is correct
13 Correct 1 ms 8540 KB Output is correct
14 Correct 2 ms 8536 KB Output is correct
15 Correct 2 ms 8540 KB Output is correct
16 Correct 1 ms 8540 KB Output is correct
17 Correct 1 ms 8540 KB Output is correct
18 Correct 1 ms 8540 KB Output is correct
19 Correct 1 ms 8656 KB Output is correct
20 Correct 1 ms 8536 KB Output is correct
21 Correct 2 ms 8536 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 1 ms 8616 KB Output is correct
24 Correct 1 ms 8540 KB Output is correct
25 Correct 1 ms 8540 KB Output is correct
26 Correct 1 ms 8540 KB Output is correct
27 Correct 1 ms 8536 KB Output is correct
28 Correct 1 ms 8540 KB Output is correct
29 Correct 1 ms 8536 KB Output is correct
30 Correct 1 ms 8540 KB Output is correct
31 Correct 2 ms 8668 KB Output is correct
32 Correct 2 ms 8540 KB Output is correct
33 Correct 1 ms 8540 KB Output is correct
34 Correct 1 ms 8540 KB Output is correct
35 Correct 1 ms 8540 KB Output is correct
36 Correct 1 ms 8540 KB Output is correct
37 Correct 1 ms 8544 KB Output is correct
38 Correct 1 ms 8672 KB Output is correct
39 Correct 2 ms 8548 KB Output is correct
40 Correct 1 ms 8540 KB Output is correct
41 Correct 2 ms 8540 KB Output is correct
42 Correct 1 ms 8548 KB Output is correct
43 Correct 1 ms 8664 KB Output is correct
44 Correct 2 ms 8536 KB Output is correct
45 Correct 1 ms 8552 KB Output is correct
46 Correct 1 ms 8664 KB Output is correct
47 Correct 1 ms 8540 KB Output is correct
48 Correct 1 ms 8540 KB Output is correct
49 Correct 1 ms 8792 KB Output is correct
50 Correct 2 ms 8552 KB Output is correct
51 Correct 2 ms 8540 KB Output is correct
52 Correct 1 ms 8540 KB Output is correct
53 Correct 1 ms 8540 KB Output is correct
54 Correct 1 ms 8540 KB Output is correct
55 Correct 1 ms 8656 KB Output is correct
56 Correct 2 ms 8540 KB Output is correct
57 Correct 2 ms 8536 KB Output is correct
58 Correct 1 ms 8540 KB Output is correct
59 Correct 1 ms 8540 KB Output is correct
60 Correct 1 ms 8540 KB Output is correct
61 Correct 1 ms 8676 KB Output is correct
62 Runtime error 6 ms 8796 KB Execution killed with signal 11
63 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8540 KB Output is correct
2 Correct 1 ms 8536 KB Output is correct
3 Correct 1 ms 8536 KB Output is correct
4 Correct 2 ms 8536 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8652 KB Output is correct
7 Correct 2 ms 8540 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 1 ms 8540 KB Output is correct
10 Correct 1 ms 8536 KB Output is correct
11 Correct 1 ms 8656 KB Output is correct
12 Correct 2 ms 8776 KB Output is correct
13 Correct 1 ms 8540 KB Output is correct
14 Correct 2 ms 8536 KB Output is correct
15 Correct 2 ms 8540 KB Output is correct
16 Correct 1 ms 8540 KB Output is correct
17 Correct 1 ms 8540 KB Output is correct
18 Correct 1 ms 8540 KB Output is correct
19 Correct 1 ms 8656 KB Output is correct
20 Correct 1 ms 8536 KB Output is correct
21 Correct 2 ms 8536 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 1 ms 8616 KB Output is correct
24 Correct 1 ms 8540 KB Output is correct
25 Correct 1 ms 8540 KB Output is correct
26 Correct 1 ms 8540 KB Output is correct
27 Correct 1 ms 8536 KB Output is correct
28 Correct 1 ms 8540 KB Output is correct
29 Correct 1 ms 8536 KB Output is correct
30 Correct 1 ms 8540 KB Output is correct
31 Correct 2 ms 8668 KB Output is correct
32 Correct 2 ms 8540 KB Output is correct
33 Correct 1 ms 8540 KB Output is correct
34 Correct 1 ms 8540 KB Output is correct
35 Correct 1 ms 8540 KB Output is correct
36 Correct 1 ms 8540 KB Output is correct
37 Correct 1 ms 8544 KB Output is correct
38 Correct 1 ms 8672 KB Output is correct
39 Correct 2 ms 8548 KB Output is correct
40 Correct 1 ms 8540 KB Output is correct
41 Correct 2 ms 8540 KB Output is correct
42 Correct 1 ms 8548 KB Output is correct
43 Correct 1 ms 8664 KB Output is correct
44 Correct 2 ms 8536 KB Output is correct
45 Correct 1 ms 8552 KB Output is correct
46 Correct 1 ms 8664 KB Output is correct
47 Correct 1 ms 8540 KB Output is correct
48 Correct 1 ms 8540 KB Output is correct
49 Correct 1 ms 8792 KB Output is correct
50 Correct 2 ms 8552 KB Output is correct
51 Correct 2 ms 8540 KB Output is correct
52 Correct 1 ms 8540 KB Output is correct
53 Correct 1 ms 8540 KB Output is correct
54 Correct 1 ms 8540 KB Output is correct
55 Correct 1 ms 8656 KB Output is correct
56 Correct 2 ms 8540 KB Output is correct
57 Runtime error 23 ms 32416 KB Execution killed with signal 11
58 Halted 0 ms 0 KB -