#include<bits/stdc++.h>
using namespace std;
int type[1000005];
int cur=0;
string s;
struct node{
int st,en,sz;
node(int _st=0,int _en=0,int _sz=0){
st=_st,en=_en,sz=_sz;
}
friend node operator+(node a,node b){
node c;
c.st=a.st+b.st;
c.en=max(a.en+b.sz,b.en+a.sz);
c.sz=a.sz+b.sz;
return c;
}
friend node operator-(node a,node b){
node c;
c.st=min(a.st,b.st);
c.en=a.en+b.en-1;
c.sz=a.sz+b.sz;
return c;
}
}info[10000005];
int dfs(int u,int st){
int id1,st1,en1,id2,st2,en2;
if(s[st]=='?'){
info[u]=node(1,1,1);
return st;
}else if(s[st+1]=='i'){
id1=cur+1;
st1=st+4;
en1=dfs(++cur,st1);
id2=cur+1;
st2=en1+2;
en2=dfs(++cur,st2);
info[u]=info[id1]-info[id2];
return en2+1;
}else{
id1=cur+1;
st1=st+4;
en1=dfs(++cur,st1);
id2=cur+1;
st2=en1+2;
en2=dfs(++cur,st2);
info[u]=info[id1]+info[id2];
return en2+1;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>s;
dfs(++cur,0);
cout<<info[1].en-info[1].st+1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
119644 KB |
Output is correct |
2 |
Correct |
19 ms |
119644 KB |
Output is correct |
3 |
Correct |
19 ms |
119588 KB |
Output is correct |
4 |
Correct |
18 ms |
119452 KB |
Output is correct |
5 |
Correct |
19 ms |
119540 KB |
Output is correct |
6 |
Correct |
19 ms |
119424 KB |
Output is correct |
7 |
Correct |
21 ms |
119896 KB |
Output is correct |
8 |
Correct |
18 ms |
119540 KB |
Output is correct |
9 |
Correct |
19 ms |
119896 KB |
Output is correct |
10 |
Correct |
18 ms |
119644 KB |
Output is correct |
11 |
Correct |
22 ms |
119640 KB |
Output is correct |
12 |
Correct |
21 ms |
119392 KB |
Output is correct |
13 |
Correct |
18 ms |
119644 KB |
Output is correct |
14 |
Correct |
18 ms |
119508 KB |
Output is correct |
15 |
Correct |
18 ms |
119644 KB |
Output is correct |
16 |
Correct |
18 ms |
119632 KB |
Output is correct |
17 |
Correct |
18 ms |
119560 KB |
Output is correct |
18 |
Correct |
18 ms |
119644 KB |
Output is correct |
19 |
Correct |
21 ms |
119644 KB |
Output is correct |
20 |
Correct |
18 ms |
119592 KB |
Output is correct |
21 |
Correct |
18 ms |
119560 KB |
Output is correct |
22 |
Correct |
18 ms |
119644 KB |
Output is correct |
23 |
Correct |
19 ms |
119644 KB |
Output is correct |
24 |
Correct |
18 ms |
119540 KB |
Output is correct |
25 |
Correct |
18 ms |
119508 KB |
Output is correct |
26 |
Correct |
21 ms |
119644 KB |
Output is correct |
27 |
Correct |
19 ms |
119644 KB |
Output is correct |
28 |
Correct |
18 ms |
119480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
119644 KB |
Output is correct |
2 |
Correct |
19 ms |
119644 KB |
Output is correct |
3 |
Correct |
19 ms |
119588 KB |
Output is correct |
4 |
Correct |
18 ms |
119452 KB |
Output is correct |
5 |
Correct |
19 ms |
119540 KB |
Output is correct |
6 |
Correct |
19 ms |
119424 KB |
Output is correct |
7 |
Correct |
21 ms |
119896 KB |
Output is correct |
8 |
Correct |
18 ms |
119540 KB |
Output is correct |
9 |
Correct |
19 ms |
119896 KB |
Output is correct |
10 |
Correct |
18 ms |
119644 KB |
Output is correct |
11 |
Correct |
22 ms |
119640 KB |
Output is correct |
12 |
Correct |
21 ms |
119392 KB |
Output is correct |
13 |
Correct |
18 ms |
119644 KB |
Output is correct |
14 |
Correct |
18 ms |
119508 KB |
Output is correct |
15 |
Correct |
18 ms |
119644 KB |
Output is correct |
16 |
Correct |
18 ms |
119632 KB |
Output is correct |
17 |
Correct |
18 ms |
119560 KB |
Output is correct |
18 |
Correct |
18 ms |
119644 KB |
Output is correct |
19 |
Correct |
21 ms |
119644 KB |
Output is correct |
20 |
Correct |
18 ms |
119592 KB |
Output is correct |
21 |
Correct |
18 ms |
119560 KB |
Output is correct |
22 |
Correct |
18 ms |
119644 KB |
Output is correct |
23 |
Correct |
19 ms |
119644 KB |
Output is correct |
24 |
Correct |
18 ms |
119540 KB |
Output is correct |
25 |
Correct |
18 ms |
119508 KB |
Output is correct |
26 |
Correct |
21 ms |
119644 KB |
Output is correct |
27 |
Correct |
19 ms |
119644 KB |
Output is correct |
28 |
Correct |
18 ms |
119480 KB |
Output is correct |
29 |
Correct |
20 ms |
119644 KB |
Output is correct |
30 |
Correct |
18 ms |
119640 KB |
Output is correct |
31 |
Correct |
17 ms |
119644 KB |
Output is correct |
32 |
Correct |
18 ms |
119644 KB |
Output is correct |
33 |
Correct |
18 ms |
119444 KB |
Output is correct |
34 |
Correct |
19 ms |
119644 KB |
Output is correct |
35 |
Correct |
20 ms |
119552 KB |
Output is correct |
36 |
Correct |
18 ms |
119640 KB |
Output is correct |
37 |
Correct |
18 ms |
119632 KB |
Output is correct |
38 |
Correct |
20 ms |
119588 KB |
Output is correct |
39 |
Correct |
18 ms |
119640 KB |
Output is correct |
40 |
Correct |
18 ms |
119596 KB |
Output is correct |
41 |
Correct |
18 ms |
119644 KB |
Output is correct |
42 |
Correct |
18 ms |
119592 KB |
Output is correct |
43 |
Correct |
20 ms |
119644 KB |
Output is correct |
44 |
Correct |
21 ms |
119644 KB |
Output is correct |
45 |
Correct |
18 ms |
119644 KB |
Output is correct |
46 |
Correct |
18 ms |
119460 KB |
Output is correct |
47 |
Correct |
21 ms |
119644 KB |
Output is correct |
48 |
Correct |
21 ms |
119544 KB |
Output is correct |
49 |
Correct |
22 ms |
119644 KB |
Output is correct |
50 |
Correct |
18 ms |
119528 KB |
Output is correct |
51 |
Correct |
21 ms |
119644 KB |
Output is correct |
52 |
Correct |
21 ms |
119528 KB |
Output is correct |
53 |
Correct |
18 ms |
119644 KB |
Output is correct |
54 |
Correct |
18 ms |
119624 KB |
Output is correct |
55 |
Correct |
18 ms |
119644 KB |
Output is correct |
56 |
Correct |
18 ms |
119564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
173516 KB |
Output is correct |
2 |
Correct |
65 ms |
173524 KB |
Output is correct |
3 |
Correct |
65 ms |
173380 KB |
Output is correct |
4 |
Correct |
64 ms |
173492 KB |
Output is correct |
5 |
Correct |
60 ms |
173516 KB |
Output is correct |
6 |
Correct |
61 ms |
173512 KB |
Output is correct |
7 |
Correct |
67 ms |
173532 KB |
Output is correct |
8 |
Correct |
59 ms |
173448 KB |
Output is correct |
9 |
Correct |
61 ms |
173360 KB |
Output is correct |
10 |
Correct |
70 ms |
173400 KB |
Output is correct |
11 |
Correct |
62 ms |
173540 KB |
Output is correct |
12 |
Correct |
61 ms |
173440 KB |
Output is correct |
13 |
Correct |
18 ms |
119568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
119644 KB |
Output is correct |
2 |
Correct |
19 ms |
119644 KB |
Output is correct |
3 |
Correct |
19 ms |
119588 KB |
Output is correct |
4 |
Correct |
18 ms |
119452 KB |
Output is correct |
5 |
Correct |
19 ms |
119540 KB |
Output is correct |
6 |
Correct |
19 ms |
119424 KB |
Output is correct |
7 |
Correct |
21 ms |
119896 KB |
Output is correct |
8 |
Correct |
18 ms |
119540 KB |
Output is correct |
9 |
Correct |
19 ms |
119896 KB |
Output is correct |
10 |
Correct |
18 ms |
119644 KB |
Output is correct |
11 |
Correct |
22 ms |
119640 KB |
Output is correct |
12 |
Correct |
21 ms |
119392 KB |
Output is correct |
13 |
Correct |
18 ms |
119644 KB |
Output is correct |
14 |
Correct |
18 ms |
119508 KB |
Output is correct |
15 |
Correct |
18 ms |
119644 KB |
Output is correct |
16 |
Correct |
18 ms |
119632 KB |
Output is correct |
17 |
Correct |
18 ms |
119560 KB |
Output is correct |
18 |
Correct |
18 ms |
119644 KB |
Output is correct |
19 |
Correct |
21 ms |
119644 KB |
Output is correct |
20 |
Correct |
18 ms |
119592 KB |
Output is correct |
21 |
Correct |
18 ms |
119560 KB |
Output is correct |
22 |
Correct |
18 ms |
119644 KB |
Output is correct |
23 |
Correct |
19 ms |
119644 KB |
Output is correct |
24 |
Correct |
18 ms |
119540 KB |
Output is correct |
25 |
Correct |
18 ms |
119508 KB |
Output is correct |
26 |
Correct |
21 ms |
119644 KB |
Output is correct |
27 |
Correct |
19 ms |
119644 KB |
Output is correct |
28 |
Correct |
18 ms |
119480 KB |
Output is correct |
29 |
Correct |
20 ms |
119644 KB |
Output is correct |
30 |
Correct |
18 ms |
119640 KB |
Output is correct |
31 |
Correct |
17 ms |
119644 KB |
Output is correct |
32 |
Correct |
18 ms |
119644 KB |
Output is correct |
33 |
Correct |
18 ms |
119444 KB |
Output is correct |
34 |
Correct |
19 ms |
119644 KB |
Output is correct |
35 |
Correct |
20 ms |
119552 KB |
Output is correct |
36 |
Correct |
18 ms |
119640 KB |
Output is correct |
37 |
Correct |
18 ms |
119632 KB |
Output is correct |
38 |
Correct |
20 ms |
119588 KB |
Output is correct |
39 |
Correct |
18 ms |
119640 KB |
Output is correct |
40 |
Correct |
18 ms |
119596 KB |
Output is correct |
41 |
Correct |
18 ms |
119644 KB |
Output is correct |
42 |
Correct |
18 ms |
119592 KB |
Output is correct |
43 |
Correct |
20 ms |
119644 KB |
Output is correct |
44 |
Correct |
21 ms |
119644 KB |
Output is correct |
45 |
Correct |
18 ms |
119644 KB |
Output is correct |
46 |
Correct |
18 ms |
119460 KB |
Output is correct |
47 |
Correct |
21 ms |
119644 KB |
Output is correct |
48 |
Correct |
21 ms |
119544 KB |
Output is correct |
49 |
Correct |
22 ms |
119644 KB |
Output is correct |
50 |
Correct |
18 ms |
119528 KB |
Output is correct |
51 |
Correct |
21 ms |
119644 KB |
Output is correct |
52 |
Correct |
21 ms |
119528 KB |
Output is correct |
53 |
Correct |
18 ms |
119644 KB |
Output is correct |
54 |
Correct |
18 ms |
119624 KB |
Output is correct |
55 |
Correct |
18 ms |
119644 KB |
Output is correct |
56 |
Correct |
18 ms |
119564 KB |
Output is correct |
57 |
Correct |
18 ms |
119640 KB |
Output is correct |
58 |
Correct |
18 ms |
119440 KB |
Output is correct |
59 |
Correct |
21 ms |
119640 KB |
Output is correct |
60 |
Correct |
18 ms |
119644 KB |
Output is correct |
61 |
Correct |
18 ms |
119644 KB |
Output is correct |
62 |
Correct |
18 ms |
119632 KB |
Output is correct |
63 |
Correct |
18 ms |
119636 KB |
Output is correct |
64 |
Correct |
18 ms |
119644 KB |
Output is correct |
65 |
Correct |
18 ms |
119496 KB |
Output is correct |
66 |
Correct |
18 ms |
119644 KB |
Output is correct |
67 |
Correct |
21 ms |
119644 KB |
Output is correct |
68 |
Correct |
18 ms |
119508 KB |
Output is correct |
69 |
Correct |
18 ms |
119544 KB |
Output is correct |
70 |
Correct |
18 ms |
119536 KB |
Output is correct |
71 |
Correct |
19 ms |
119644 KB |
Output is correct |
72 |
Correct |
18 ms |
119652 KB |
Output is correct |
73 |
Correct |
18 ms |
119644 KB |
Output is correct |
74 |
Correct |
18 ms |
119640 KB |
Output is correct |
75 |
Correct |
18 ms |
119644 KB |
Output is correct |
76 |
Correct |
18 ms |
119644 KB |
Output is correct |
77 |
Correct |
18 ms |
119644 KB |
Output is correct |
78 |
Correct |
22 ms |
119568 KB |
Output is correct |
79 |
Correct |
18 ms |
119436 KB |
Output is correct |
80 |
Correct |
18 ms |
119644 KB |
Output is correct |
81 |
Correct |
18 ms |
119504 KB |
Output is correct |
82 |
Correct |
18 ms |
119560 KB |
Output is correct |
83 |
Correct |
19 ms |
119644 KB |
Output is correct |
84 |
Correct |
20 ms |
119644 KB |
Output is correct |
85 |
Correct |
18 ms |
119604 KB |
Output is correct |
86 |
Correct |
18 ms |
119644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
119644 KB |
Output is correct |
2 |
Correct |
19 ms |
119644 KB |
Output is correct |
3 |
Correct |
19 ms |
119588 KB |
Output is correct |
4 |
Correct |
18 ms |
119452 KB |
Output is correct |
5 |
Correct |
19 ms |
119540 KB |
Output is correct |
6 |
Correct |
19 ms |
119424 KB |
Output is correct |
7 |
Correct |
21 ms |
119896 KB |
Output is correct |
8 |
Correct |
18 ms |
119540 KB |
Output is correct |
9 |
Correct |
19 ms |
119896 KB |
Output is correct |
10 |
Correct |
18 ms |
119644 KB |
Output is correct |
11 |
Correct |
22 ms |
119640 KB |
Output is correct |
12 |
Correct |
21 ms |
119392 KB |
Output is correct |
13 |
Correct |
18 ms |
119644 KB |
Output is correct |
14 |
Correct |
18 ms |
119508 KB |
Output is correct |
15 |
Correct |
18 ms |
119644 KB |
Output is correct |
16 |
Correct |
18 ms |
119632 KB |
Output is correct |
17 |
Correct |
18 ms |
119560 KB |
Output is correct |
18 |
Correct |
18 ms |
119644 KB |
Output is correct |
19 |
Correct |
21 ms |
119644 KB |
Output is correct |
20 |
Correct |
18 ms |
119592 KB |
Output is correct |
21 |
Correct |
18 ms |
119560 KB |
Output is correct |
22 |
Correct |
18 ms |
119644 KB |
Output is correct |
23 |
Correct |
19 ms |
119644 KB |
Output is correct |
24 |
Correct |
18 ms |
119540 KB |
Output is correct |
25 |
Correct |
18 ms |
119508 KB |
Output is correct |
26 |
Correct |
21 ms |
119644 KB |
Output is correct |
27 |
Correct |
19 ms |
119644 KB |
Output is correct |
28 |
Correct |
18 ms |
119480 KB |
Output is correct |
29 |
Correct |
20 ms |
119644 KB |
Output is correct |
30 |
Correct |
18 ms |
119640 KB |
Output is correct |
31 |
Correct |
17 ms |
119644 KB |
Output is correct |
32 |
Correct |
18 ms |
119644 KB |
Output is correct |
33 |
Correct |
18 ms |
119444 KB |
Output is correct |
34 |
Correct |
19 ms |
119644 KB |
Output is correct |
35 |
Correct |
20 ms |
119552 KB |
Output is correct |
36 |
Correct |
18 ms |
119640 KB |
Output is correct |
37 |
Correct |
18 ms |
119632 KB |
Output is correct |
38 |
Correct |
20 ms |
119588 KB |
Output is correct |
39 |
Correct |
18 ms |
119640 KB |
Output is correct |
40 |
Correct |
18 ms |
119596 KB |
Output is correct |
41 |
Correct |
18 ms |
119644 KB |
Output is correct |
42 |
Correct |
18 ms |
119592 KB |
Output is correct |
43 |
Correct |
20 ms |
119644 KB |
Output is correct |
44 |
Correct |
21 ms |
119644 KB |
Output is correct |
45 |
Correct |
18 ms |
119644 KB |
Output is correct |
46 |
Correct |
18 ms |
119460 KB |
Output is correct |
47 |
Correct |
21 ms |
119644 KB |
Output is correct |
48 |
Correct |
21 ms |
119544 KB |
Output is correct |
49 |
Correct |
22 ms |
119644 KB |
Output is correct |
50 |
Correct |
18 ms |
119528 KB |
Output is correct |
51 |
Correct |
21 ms |
119644 KB |
Output is correct |
52 |
Correct |
21 ms |
119528 KB |
Output is correct |
53 |
Correct |
18 ms |
119644 KB |
Output is correct |
54 |
Correct |
18 ms |
119624 KB |
Output is correct |
55 |
Correct |
18 ms |
119644 KB |
Output is correct |
56 |
Correct |
18 ms |
119564 KB |
Output is correct |
57 |
Correct |
61 ms |
173516 KB |
Output is correct |
58 |
Correct |
65 ms |
173524 KB |
Output is correct |
59 |
Correct |
65 ms |
173380 KB |
Output is correct |
60 |
Correct |
64 ms |
173492 KB |
Output is correct |
61 |
Correct |
60 ms |
173516 KB |
Output is correct |
62 |
Correct |
61 ms |
173512 KB |
Output is correct |
63 |
Correct |
67 ms |
173532 KB |
Output is correct |
64 |
Correct |
59 ms |
173448 KB |
Output is correct |
65 |
Correct |
61 ms |
173360 KB |
Output is correct |
66 |
Correct |
70 ms |
173400 KB |
Output is correct |
67 |
Correct |
62 ms |
173540 KB |
Output is correct |
68 |
Correct |
61 ms |
173440 KB |
Output is correct |
69 |
Correct |
18 ms |
119568 KB |
Output is correct |
70 |
Correct |
18 ms |
119640 KB |
Output is correct |
71 |
Correct |
18 ms |
119440 KB |
Output is correct |
72 |
Correct |
21 ms |
119640 KB |
Output is correct |
73 |
Correct |
18 ms |
119644 KB |
Output is correct |
74 |
Correct |
18 ms |
119644 KB |
Output is correct |
75 |
Correct |
18 ms |
119632 KB |
Output is correct |
76 |
Correct |
18 ms |
119636 KB |
Output is correct |
77 |
Correct |
18 ms |
119644 KB |
Output is correct |
78 |
Correct |
18 ms |
119496 KB |
Output is correct |
79 |
Correct |
18 ms |
119644 KB |
Output is correct |
80 |
Correct |
21 ms |
119644 KB |
Output is correct |
81 |
Correct |
18 ms |
119508 KB |
Output is correct |
82 |
Correct |
18 ms |
119544 KB |
Output is correct |
83 |
Correct |
18 ms |
119536 KB |
Output is correct |
84 |
Correct |
19 ms |
119644 KB |
Output is correct |
85 |
Correct |
18 ms |
119652 KB |
Output is correct |
86 |
Correct |
18 ms |
119644 KB |
Output is correct |
87 |
Correct |
18 ms |
119640 KB |
Output is correct |
88 |
Correct |
18 ms |
119644 KB |
Output is correct |
89 |
Correct |
18 ms |
119644 KB |
Output is correct |
90 |
Correct |
18 ms |
119644 KB |
Output is correct |
91 |
Correct |
22 ms |
119568 KB |
Output is correct |
92 |
Correct |
18 ms |
119436 KB |
Output is correct |
93 |
Correct |
18 ms |
119644 KB |
Output is correct |
94 |
Correct |
18 ms |
119504 KB |
Output is correct |
95 |
Correct |
18 ms |
119560 KB |
Output is correct |
96 |
Correct |
19 ms |
119644 KB |
Output is correct |
97 |
Correct |
20 ms |
119644 KB |
Output is correct |
98 |
Correct |
18 ms |
119604 KB |
Output is correct |
99 |
Correct |
18 ms |
119644 KB |
Output is correct |
100 |
Correct |
38 ms |
128004 KB |
Output is correct |
101 |
Correct |
38 ms |
127960 KB |
Output is correct |
102 |
Correct |
36 ms |
127968 KB |
Output is correct |
103 |
Correct |
38 ms |
127960 KB |
Output is correct |
104 |
Correct |
40 ms |
127972 KB |
Output is correct |
105 |
Correct |
49 ms |
142040 KB |
Output is correct |
106 |
Correct |
48 ms |
142072 KB |
Output is correct |
107 |
Correct |
44 ms |
142040 KB |
Output is correct |
108 |
Correct |
44 ms |
142040 KB |
Output is correct |
109 |
Correct |
43 ms |
142308 KB |
Output is correct |
110 |
Correct |
41 ms |
127904 KB |
Output is correct |
111 |
Correct |
41 ms |
127972 KB |
Output is correct |
112 |
Correct |
36 ms |
127968 KB |
Output is correct |
113 |
Correct |
45 ms |
127972 KB |
Output is correct |
114 |
Correct |
36 ms |
127972 KB |
Output is correct |
115 |
Correct |
64 ms |
173536 KB |
Output is correct |
116 |
Correct |
66 ms |
173528 KB |
Output is correct |
117 |
Correct |
62 ms |
173448 KB |
Output is correct |
118 |
Correct |
62 ms |
173484 KB |
Output is correct |
119 |
Correct |
69 ms |
173512 KB |
Output is correct |
120 |
Correct |
35 ms |
127976 KB |
Output is correct |
121 |
Correct |
42 ms |
127872 KB |
Output is correct |
122 |
Correct |
39 ms |
127960 KB |
Output is correct |
123 |
Correct |
40 ms |
127972 KB |
Output is correct |
124 |
Correct |
48 ms |
149980 KB |
Output is correct |
125 |
Correct |
49 ms |
150092 KB |
Output is correct |
126 |
Correct |
51 ms |
149976 KB |
Output is correct |
127 |
Correct |
48 ms |
149980 KB |
Output is correct |
128 |
Correct |
27 ms |
123864 KB |
Output is correct |
129 |
Correct |
29 ms |
123788 KB |
Output is correct |
130 |
Correct |
25 ms |
123864 KB |
Output is correct |
131 |
Correct |
18 ms |
119644 KB |
Output is correct |