Submission #970028

# Submission time Handle Problem Language Result Execution time Memory
970028 2024-04-26T06:52:15 Z 12345678 Homework (CEOI22_homework) C++17
100 / 100
207 ms 225120 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=4e6+5;

int n, t[nx], sz[nx], mn[nx], mx[nx], cnt;
vector<int> d[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;
    d[i].push_back(++cnt);
    int tmp=build(l+4, cnt);
    l=tmp+2;
    d[i].push_back(++cnt);
    tmp=build(l, cnt);
    return tmp+1; 
}

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

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>s;
    cnt=1;
    n=s.size();
    build(0, 1);
    solve(1);
    cout<<mx[1]-mn[1]+1;
}
# Verdict Execution time Memory Grader output
1 Correct 47 ms 100944 KB Output is correct
2 Correct 26 ms 101212 KB Output is correct
3 Correct 23 ms 100956 KB Output is correct
4 Correct 23 ms 101188 KB Output is correct
5 Correct 22 ms 100952 KB Output is correct
6 Correct 33 ms 100948 KB Output is correct
7 Correct 22 ms 100956 KB Output is correct
8 Correct 22 ms 100952 KB Output is correct
9 Correct 24 ms 100956 KB Output is correct
10 Correct 25 ms 101212 KB Output is correct
11 Correct 22 ms 100956 KB Output is correct
12 Correct 25 ms 101012 KB Output is correct
13 Correct 22 ms 101088 KB Output is correct
14 Correct 22 ms 101040 KB Output is correct
15 Correct 25 ms 100956 KB Output is correct
16 Correct 22 ms 100956 KB Output is correct
17 Correct 27 ms 100956 KB Output is correct
18 Correct 23 ms 100956 KB Output is correct
19 Correct 22 ms 101080 KB Output is correct
20 Correct 23 ms 101176 KB Output is correct
21 Correct 22 ms 100956 KB Output is correct
22 Correct 27 ms 100956 KB Output is correct
23 Correct 25 ms 101156 KB Output is correct
24 Correct 22 ms 100956 KB Output is correct
25 Correct 22 ms 100952 KB Output is correct
26 Correct 23 ms 101084 KB Output is correct
27 Correct 24 ms 100952 KB Output is correct
28 Correct 23 ms 101088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 100944 KB Output is correct
2 Correct 26 ms 101212 KB Output is correct
3 Correct 23 ms 100956 KB Output is correct
4 Correct 23 ms 101188 KB Output is correct
5 Correct 22 ms 100952 KB Output is correct
6 Correct 33 ms 100948 KB Output is correct
7 Correct 22 ms 100956 KB Output is correct
8 Correct 22 ms 100952 KB Output is correct
9 Correct 24 ms 100956 KB Output is correct
10 Correct 25 ms 101212 KB Output is correct
11 Correct 22 ms 100956 KB Output is correct
12 Correct 25 ms 101012 KB Output is correct
13 Correct 22 ms 101088 KB Output is correct
14 Correct 22 ms 101040 KB Output is correct
15 Correct 25 ms 100956 KB Output is correct
16 Correct 22 ms 100956 KB Output is correct
17 Correct 27 ms 100956 KB Output is correct
18 Correct 23 ms 100956 KB Output is correct
19 Correct 22 ms 101080 KB Output is correct
20 Correct 23 ms 101176 KB Output is correct
21 Correct 22 ms 100956 KB Output is correct
22 Correct 27 ms 100956 KB Output is correct
23 Correct 25 ms 101156 KB Output is correct
24 Correct 22 ms 100956 KB Output is correct
25 Correct 22 ms 100952 KB Output is correct
26 Correct 23 ms 101084 KB Output is correct
27 Correct 24 ms 100952 KB Output is correct
28 Correct 23 ms 101088 KB Output is correct
29 Correct 36 ms 100944 KB Output is correct
30 Correct 22 ms 100952 KB Output is correct
31 Correct 22 ms 100956 KB Output is correct
32 Correct 25 ms 100956 KB Output is correct
33 Correct 22 ms 101176 KB Output is correct
34 Correct 24 ms 100956 KB Output is correct
35 Correct 24 ms 101112 KB Output is correct
36 Correct 23 ms 100956 KB Output is correct
37 Correct 23 ms 101184 KB Output is correct
38 Correct 23 ms 101180 KB Output is correct
39 Correct 23 ms 101184 KB Output is correct
40 Correct 24 ms 100956 KB Output is correct
41 Correct 23 ms 100956 KB Output is correct
42 Correct 25 ms 100956 KB Output is correct
43 Correct 24 ms 100956 KB Output is correct
44 Correct 24 ms 100956 KB Output is correct
45 Correct 25 ms 101184 KB Output is correct
46 Correct 22 ms 100992 KB Output is correct
47 Correct 22 ms 100956 KB Output is correct
48 Correct 24 ms 100956 KB Output is correct
49 Correct 22 ms 100952 KB Output is correct
50 Correct 22 ms 100956 KB Output is correct
51 Correct 26 ms 100956 KB Output is correct
52 Correct 23 ms 100956 KB Output is correct
53 Correct 23 ms 101184 KB Output is correct
54 Correct 25 ms 101284 KB Output is correct
55 Correct 22 ms 100952 KB Output is correct
56 Correct 23 ms 100956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 174 ms 214652 KB Output is correct
2 Correct 187 ms 220576 KB Output is correct
3 Correct 192 ms 221492 KB Output is correct
4 Correct 207 ms 223700 KB Output is correct
5 Correct 176 ms 224124 KB Output is correct
6 Correct 200 ms 224692 KB Output is correct
7 Correct 180 ms 224424 KB Output is correct
8 Correct 168 ms 223880 KB Output is correct
9 Correct 174 ms 225120 KB Output is correct
10 Correct 183 ms 224564 KB Output is correct
11 Correct 168 ms 223696 KB Output is correct
12 Correct 169 ms 223684 KB Output is correct
13 Correct 25 ms 101152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 100944 KB Output is correct
2 Correct 26 ms 101212 KB Output is correct
3 Correct 23 ms 100956 KB Output is correct
4 Correct 23 ms 101188 KB Output is correct
5 Correct 22 ms 100952 KB Output is correct
6 Correct 33 ms 100948 KB Output is correct
7 Correct 22 ms 100956 KB Output is correct
8 Correct 22 ms 100952 KB Output is correct
9 Correct 24 ms 100956 KB Output is correct
10 Correct 25 ms 101212 KB Output is correct
11 Correct 22 ms 100956 KB Output is correct
12 Correct 25 ms 101012 KB Output is correct
13 Correct 22 ms 101088 KB Output is correct
14 Correct 22 ms 101040 KB Output is correct
15 Correct 25 ms 100956 KB Output is correct
16 Correct 22 ms 100956 KB Output is correct
17 Correct 27 ms 100956 KB Output is correct
18 Correct 23 ms 100956 KB Output is correct
19 Correct 22 ms 101080 KB Output is correct
20 Correct 23 ms 101176 KB Output is correct
21 Correct 22 ms 100956 KB Output is correct
22 Correct 27 ms 100956 KB Output is correct
23 Correct 25 ms 101156 KB Output is correct
24 Correct 22 ms 100956 KB Output is correct
25 Correct 22 ms 100952 KB Output is correct
26 Correct 23 ms 101084 KB Output is correct
27 Correct 24 ms 100952 KB Output is correct
28 Correct 23 ms 101088 KB Output is correct
29 Correct 36 ms 100944 KB Output is correct
30 Correct 22 ms 100952 KB Output is correct
31 Correct 22 ms 100956 KB Output is correct
32 Correct 25 ms 100956 KB Output is correct
33 Correct 22 ms 101176 KB Output is correct
34 Correct 24 ms 100956 KB Output is correct
35 Correct 24 ms 101112 KB Output is correct
36 Correct 23 ms 100956 KB Output is correct
37 Correct 23 ms 101184 KB Output is correct
38 Correct 23 ms 101180 KB Output is correct
39 Correct 23 ms 101184 KB Output is correct
40 Correct 24 ms 100956 KB Output is correct
41 Correct 23 ms 100956 KB Output is correct
42 Correct 25 ms 100956 KB Output is correct
43 Correct 24 ms 100956 KB Output is correct
44 Correct 24 ms 100956 KB Output is correct
45 Correct 25 ms 101184 KB Output is correct
46 Correct 22 ms 100992 KB Output is correct
47 Correct 22 ms 100956 KB Output is correct
48 Correct 24 ms 100956 KB Output is correct
49 Correct 22 ms 100952 KB Output is correct
50 Correct 22 ms 100956 KB Output is correct
51 Correct 26 ms 100956 KB Output is correct
52 Correct 23 ms 100956 KB Output is correct
53 Correct 23 ms 101184 KB Output is correct
54 Correct 25 ms 101284 KB Output is correct
55 Correct 22 ms 100952 KB Output is correct
56 Correct 23 ms 100956 KB Output is correct
57 Correct 22 ms 101228 KB Output is correct
58 Correct 23 ms 101072 KB Output is correct
59 Correct 23 ms 101212 KB Output is correct
60 Correct 22 ms 101132 KB Output is correct
61 Correct 22 ms 101212 KB Output is correct
62 Correct 24 ms 101212 KB Output is correct
63 Correct 23 ms 101208 KB Output is correct
64 Correct 25 ms 101464 KB Output is correct
65 Correct 22 ms 101212 KB Output is correct
66 Correct 23 ms 101116 KB Output is correct
67 Correct 23 ms 101212 KB Output is correct
68 Correct 23 ms 101212 KB Output is correct
69 Correct 22 ms 101100 KB Output is correct
70 Correct 23 ms 101212 KB Output is correct
71 Correct 22 ms 101212 KB Output is correct
72 Correct 22 ms 101208 KB Output is correct
73 Correct 23 ms 101208 KB Output is correct
74 Correct 22 ms 101208 KB Output is correct
75 Correct 23 ms 101212 KB Output is correct
76 Correct 23 ms 101076 KB Output is correct
77 Correct 23 ms 101212 KB Output is correct
78 Correct 22 ms 101212 KB Output is correct
79 Correct 23 ms 101212 KB Output is correct
80 Correct 25 ms 101212 KB Output is correct
81 Correct 25 ms 101208 KB Output is correct
82 Correct 22 ms 101208 KB Output is correct
83 Correct 23 ms 100956 KB Output is correct
84 Correct 23 ms 101092 KB Output is correct
85 Correct 23 ms 100956 KB Output is correct
86 Correct 22 ms 101120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 100944 KB Output is correct
2 Correct 26 ms 101212 KB Output is correct
3 Correct 23 ms 100956 KB Output is correct
4 Correct 23 ms 101188 KB Output is correct
5 Correct 22 ms 100952 KB Output is correct
6 Correct 33 ms 100948 KB Output is correct
7 Correct 22 ms 100956 KB Output is correct
8 Correct 22 ms 100952 KB Output is correct
9 Correct 24 ms 100956 KB Output is correct
10 Correct 25 ms 101212 KB Output is correct
11 Correct 22 ms 100956 KB Output is correct
12 Correct 25 ms 101012 KB Output is correct
13 Correct 22 ms 101088 KB Output is correct
14 Correct 22 ms 101040 KB Output is correct
15 Correct 25 ms 100956 KB Output is correct
16 Correct 22 ms 100956 KB Output is correct
17 Correct 27 ms 100956 KB Output is correct
18 Correct 23 ms 100956 KB Output is correct
19 Correct 22 ms 101080 KB Output is correct
20 Correct 23 ms 101176 KB Output is correct
21 Correct 22 ms 100956 KB Output is correct
22 Correct 27 ms 100956 KB Output is correct
23 Correct 25 ms 101156 KB Output is correct
24 Correct 22 ms 100956 KB Output is correct
25 Correct 22 ms 100952 KB Output is correct
26 Correct 23 ms 101084 KB Output is correct
27 Correct 24 ms 100952 KB Output is correct
28 Correct 23 ms 101088 KB Output is correct
29 Correct 36 ms 100944 KB Output is correct
30 Correct 22 ms 100952 KB Output is correct
31 Correct 22 ms 100956 KB Output is correct
32 Correct 25 ms 100956 KB Output is correct
33 Correct 22 ms 101176 KB Output is correct
34 Correct 24 ms 100956 KB Output is correct
35 Correct 24 ms 101112 KB Output is correct
36 Correct 23 ms 100956 KB Output is correct
37 Correct 23 ms 101184 KB Output is correct
38 Correct 23 ms 101180 KB Output is correct
39 Correct 23 ms 101184 KB Output is correct
40 Correct 24 ms 100956 KB Output is correct
41 Correct 23 ms 100956 KB Output is correct
42 Correct 25 ms 100956 KB Output is correct
43 Correct 24 ms 100956 KB Output is correct
44 Correct 24 ms 100956 KB Output is correct
45 Correct 25 ms 101184 KB Output is correct
46 Correct 22 ms 100992 KB Output is correct
47 Correct 22 ms 100956 KB Output is correct
48 Correct 24 ms 100956 KB Output is correct
49 Correct 22 ms 100952 KB Output is correct
50 Correct 22 ms 100956 KB Output is correct
51 Correct 26 ms 100956 KB Output is correct
52 Correct 23 ms 100956 KB Output is correct
53 Correct 23 ms 101184 KB Output is correct
54 Correct 25 ms 101284 KB Output is correct
55 Correct 22 ms 100952 KB Output is correct
56 Correct 23 ms 100956 KB Output is correct
57 Correct 174 ms 214652 KB Output is correct
58 Correct 187 ms 220576 KB Output is correct
59 Correct 192 ms 221492 KB Output is correct
60 Correct 207 ms 223700 KB Output is correct
61 Correct 176 ms 224124 KB Output is correct
62 Correct 200 ms 224692 KB Output is correct
63 Correct 180 ms 224424 KB Output is correct
64 Correct 168 ms 223880 KB Output is correct
65 Correct 174 ms 225120 KB Output is correct
66 Correct 183 ms 224564 KB Output is correct
67 Correct 168 ms 223696 KB Output is correct
68 Correct 169 ms 223684 KB Output is correct
69 Correct 25 ms 101152 KB Output is correct
70 Correct 22 ms 101228 KB Output is correct
71 Correct 23 ms 101072 KB Output is correct
72 Correct 23 ms 101212 KB Output is correct
73 Correct 22 ms 101132 KB Output is correct
74 Correct 22 ms 101212 KB Output is correct
75 Correct 24 ms 101212 KB Output is correct
76 Correct 23 ms 101208 KB Output is correct
77 Correct 25 ms 101464 KB Output is correct
78 Correct 22 ms 101212 KB Output is correct
79 Correct 23 ms 101116 KB Output is correct
80 Correct 23 ms 101212 KB Output is correct
81 Correct 23 ms 101212 KB Output is correct
82 Correct 22 ms 101100 KB Output is correct
83 Correct 23 ms 101212 KB Output is correct
84 Correct 22 ms 101212 KB Output is correct
85 Correct 22 ms 101208 KB Output is correct
86 Correct 23 ms 101208 KB Output is correct
87 Correct 22 ms 101208 KB Output is correct
88 Correct 23 ms 101212 KB Output is correct
89 Correct 23 ms 101076 KB Output is correct
90 Correct 23 ms 101212 KB Output is correct
91 Correct 22 ms 101212 KB Output is correct
92 Correct 23 ms 101212 KB Output is correct
93 Correct 25 ms 101212 KB Output is correct
94 Correct 25 ms 101208 KB Output is correct
95 Correct 22 ms 101208 KB Output is correct
96 Correct 23 ms 100956 KB Output is correct
97 Correct 23 ms 101092 KB Output is correct
98 Correct 23 ms 100956 KB Output is correct
99 Correct 22 ms 101120 KB Output is correct
100 Correct 128 ms 178904 KB Output is correct
101 Correct 131 ms 180160 KB Output is correct
102 Correct 126 ms 179672 KB Output is correct
103 Correct 127 ms 178892 KB Output is correct
104 Correct 127 ms 178876 KB Output is correct
105 Correct 149 ms 195532 KB Output is correct
106 Correct 155 ms 194908 KB Output is correct
107 Correct 143 ms 195552 KB Output is correct
108 Correct 144 ms 195836 KB Output is correct
109 Correct 141 ms 195280 KB Output is correct
110 Correct 134 ms 179952 KB Output is correct
111 Correct 132 ms 179016 KB Output is correct
112 Correct 128 ms 179876 KB Output is correct
113 Correct 131 ms 179216 KB Output is correct
114 Correct 152 ms 179920 KB Output is correct
115 Correct 165 ms 223756 KB Output is correct
116 Correct 169 ms 223820 KB Output is correct
117 Correct 166 ms 223900 KB Output is correct
118 Correct 165 ms 223692 KB Output is correct
119 Correct 165 ms 224972 KB Output is correct
120 Correct 132 ms 179180 KB Output is correct
121 Correct 140 ms 178892 KB Output is correct
122 Correct 135 ms 179916 KB Output is correct
123 Correct 137 ms 178804 KB Output is correct
124 Correct 145 ms 202388 KB Output is correct
125 Correct 137 ms 202384 KB Output is correct
126 Correct 142 ms 201164 KB Output is correct
127 Correct 136 ms 200596 KB Output is correct
128 Correct 73 ms 141268 KB Output is correct
129 Correct 71 ms 141268 KB Output is correct
130 Correct 76 ms 141008 KB Output is correct
131 Correct 24 ms 100952 KB Output is correct