# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
994540 |
2024-06-07T19:03:05 Z |
biank |
Homework (CEOI22_homework) |
C++14 |
|
174 ms |
207060 KB |
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
const int MAX_N = 1e7;
string s;
int l[MAX_N], r[MAX_N];
struct Val {
int l, r, sz;
};
Val solve(int u) {
if (s[u] == '?') return {1, 1, 1};
Val left = solve(l[u]), right = solve(r[u]), curr;
curr.sz = left.sz + right.sz;
if (s[u] == 'n') {
curr.l = min(left.l, right.l);
curr.r = left.r + right.r - 1;
} else if (s[u] == 'x') {
curr.l = left.l + right.l;
curr.r = max(right.sz + left.r, left.sz + right.r);
} else assert(false);
return curr;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> s;
memset(l, -1, sizeof l);
memset(r, -1, sizeof r);
stack<int> st;
for (int i = 0; i < sz(s); i++) {
if (s[i] == '?' || s[i] == 'n' || s[i] == 'x') {
st.push(i);
} else if (s[i] == ',' || s[i] == ')') {
int j = st.top();
st.pop();
if (l[st.top()] == -1) l[st.top()] = j;
else r[st.top()] = j;
}
}
Val ans = solve(st.top());
cout << ans.r - ans.l + 1 << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
78680 KB |
Output is correct |
2 |
Correct |
10 ms |
78684 KB |
Output is correct |
3 |
Correct |
10 ms |
78576 KB |
Output is correct |
4 |
Correct |
9 ms |
78680 KB |
Output is correct |
5 |
Correct |
10 ms |
78684 KB |
Output is correct |
6 |
Correct |
10 ms |
78712 KB |
Output is correct |
7 |
Correct |
10 ms |
78680 KB |
Output is correct |
8 |
Correct |
10 ms |
78688 KB |
Output is correct |
9 |
Correct |
9 ms |
78736 KB |
Output is correct |
10 |
Correct |
10 ms |
78684 KB |
Output is correct |
11 |
Correct |
9 ms |
78680 KB |
Output is correct |
12 |
Correct |
9 ms |
78696 KB |
Output is correct |
13 |
Correct |
9 ms |
78684 KB |
Output is correct |
14 |
Correct |
10 ms |
78540 KB |
Output is correct |
15 |
Correct |
10 ms |
78684 KB |
Output is correct |
16 |
Correct |
10 ms |
78556 KB |
Output is correct |
17 |
Correct |
10 ms |
78684 KB |
Output is correct |
18 |
Correct |
12 ms |
78684 KB |
Output is correct |
19 |
Correct |
10 ms |
78612 KB |
Output is correct |
20 |
Correct |
10 ms |
78680 KB |
Output is correct |
21 |
Correct |
10 ms |
78708 KB |
Output is correct |
22 |
Correct |
10 ms |
78684 KB |
Output is correct |
23 |
Correct |
10 ms |
78684 KB |
Output is correct |
24 |
Correct |
9 ms |
78688 KB |
Output is correct |
25 |
Correct |
9 ms |
78684 KB |
Output is correct |
26 |
Correct |
10 ms |
78684 KB |
Output is correct |
27 |
Correct |
10 ms |
78684 KB |
Output is correct |
28 |
Correct |
10 ms |
78640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
78680 KB |
Output is correct |
2 |
Correct |
10 ms |
78684 KB |
Output is correct |
3 |
Correct |
10 ms |
78576 KB |
Output is correct |
4 |
Correct |
9 ms |
78680 KB |
Output is correct |
5 |
Correct |
10 ms |
78684 KB |
Output is correct |
6 |
Correct |
10 ms |
78712 KB |
Output is correct |
7 |
Correct |
10 ms |
78680 KB |
Output is correct |
8 |
Correct |
10 ms |
78688 KB |
Output is correct |
9 |
Correct |
9 ms |
78736 KB |
Output is correct |
10 |
Correct |
10 ms |
78684 KB |
Output is correct |
11 |
Correct |
9 ms |
78680 KB |
Output is correct |
12 |
Correct |
9 ms |
78696 KB |
Output is correct |
13 |
Correct |
9 ms |
78684 KB |
Output is correct |
14 |
Correct |
10 ms |
78540 KB |
Output is correct |
15 |
Correct |
10 ms |
78684 KB |
Output is correct |
16 |
Correct |
10 ms |
78556 KB |
Output is correct |
17 |
Correct |
10 ms |
78684 KB |
Output is correct |
18 |
Correct |
12 ms |
78684 KB |
Output is correct |
19 |
Correct |
10 ms |
78612 KB |
Output is correct |
20 |
Correct |
10 ms |
78680 KB |
Output is correct |
21 |
Correct |
10 ms |
78708 KB |
Output is correct |
22 |
Correct |
10 ms |
78684 KB |
Output is correct |
23 |
Correct |
10 ms |
78684 KB |
Output is correct |
24 |
Correct |
9 ms |
78688 KB |
Output is correct |
25 |
Correct |
9 ms |
78684 KB |
Output is correct |
26 |
Correct |
10 ms |
78684 KB |
Output is correct |
27 |
Correct |
10 ms |
78684 KB |
Output is correct |
28 |
Correct |
10 ms |
78640 KB |
Output is correct |
29 |
Correct |
10 ms |
78700 KB |
Output is correct |
30 |
Correct |
9 ms |
78668 KB |
Output is correct |
31 |
Correct |
10 ms |
78684 KB |
Output is correct |
32 |
Correct |
9 ms |
78684 KB |
Output is correct |
33 |
Correct |
9 ms |
78684 KB |
Output is correct |
34 |
Correct |
8 ms |
78620 KB |
Output is correct |
35 |
Correct |
10 ms |
78684 KB |
Output is correct |
36 |
Correct |
10 ms |
78564 KB |
Output is correct |
37 |
Correct |
9 ms |
78736 KB |
Output is correct |
38 |
Correct |
10 ms |
78680 KB |
Output is correct |
39 |
Correct |
9 ms |
78664 KB |
Output is correct |
40 |
Correct |
9 ms |
78684 KB |
Output is correct |
41 |
Correct |
9 ms |
78692 KB |
Output is correct |
42 |
Correct |
10 ms |
78684 KB |
Output is correct |
43 |
Correct |
9 ms |
78668 KB |
Output is correct |
44 |
Correct |
9 ms |
78684 KB |
Output is correct |
45 |
Correct |
10 ms |
78624 KB |
Output is correct |
46 |
Correct |
10 ms |
78712 KB |
Output is correct |
47 |
Correct |
9 ms |
78684 KB |
Output is correct |
48 |
Correct |
10 ms |
78684 KB |
Output is correct |
49 |
Correct |
10 ms |
78704 KB |
Output is correct |
50 |
Correct |
10 ms |
78680 KB |
Output is correct |
51 |
Correct |
11 ms |
78684 KB |
Output is correct |
52 |
Correct |
10 ms |
78712 KB |
Output is correct |
53 |
Correct |
10 ms |
78684 KB |
Output is correct |
54 |
Correct |
9 ms |
78544 KB |
Output is correct |
55 |
Correct |
9 ms |
78684 KB |
Output is correct |
56 |
Correct |
10 ms |
78712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
140 ms |
206240 KB |
Output is correct |
2 |
Correct |
174 ms |
206136 KB |
Output is correct |
3 |
Correct |
142 ms |
207056 KB |
Output is correct |
4 |
Correct |
143 ms |
206508 KB |
Output is correct |
5 |
Correct |
144 ms |
206200 KB |
Output is correct |
6 |
Correct |
133 ms |
206540 KB |
Output is correct |
7 |
Correct |
135 ms |
206540 KB |
Output is correct |
8 |
Correct |
132 ms |
206796 KB |
Output is correct |
9 |
Correct |
138 ms |
207052 KB |
Output is correct |
10 |
Correct |
136 ms |
206096 KB |
Output is correct |
11 |
Correct |
135 ms |
207060 KB |
Output is correct |
12 |
Correct |
128 ms |
206540 KB |
Output is correct |
13 |
Correct |
10 ms |
78704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
78680 KB |
Output is correct |
2 |
Correct |
10 ms |
78684 KB |
Output is correct |
3 |
Correct |
10 ms |
78576 KB |
Output is correct |
4 |
Correct |
9 ms |
78680 KB |
Output is correct |
5 |
Correct |
10 ms |
78684 KB |
Output is correct |
6 |
Correct |
10 ms |
78712 KB |
Output is correct |
7 |
Correct |
10 ms |
78680 KB |
Output is correct |
8 |
Correct |
10 ms |
78688 KB |
Output is correct |
9 |
Correct |
9 ms |
78736 KB |
Output is correct |
10 |
Correct |
10 ms |
78684 KB |
Output is correct |
11 |
Correct |
9 ms |
78680 KB |
Output is correct |
12 |
Correct |
9 ms |
78696 KB |
Output is correct |
13 |
Correct |
9 ms |
78684 KB |
Output is correct |
14 |
Correct |
10 ms |
78540 KB |
Output is correct |
15 |
Correct |
10 ms |
78684 KB |
Output is correct |
16 |
Correct |
10 ms |
78556 KB |
Output is correct |
17 |
Correct |
10 ms |
78684 KB |
Output is correct |
18 |
Correct |
12 ms |
78684 KB |
Output is correct |
19 |
Correct |
10 ms |
78612 KB |
Output is correct |
20 |
Correct |
10 ms |
78680 KB |
Output is correct |
21 |
Correct |
10 ms |
78708 KB |
Output is correct |
22 |
Correct |
10 ms |
78684 KB |
Output is correct |
23 |
Correct |
10 ms |
78684 KB |
Output is correct |
24 |
Correct |
9 ms |
78688 KB |
Output is correct |
25 |
Correct |
9 ms |
78684 KB |
Output is correct |
26 |
Correct |
10 ms |
78684 KB |
Output is correct |
27 |
Correct |
10 ms |
78684 KB |
Output is correct |
28 |
Correct |
10 ms |
78640 KB |
Output is correct |
29 |
Correct |
10 ms |
78700 KB |
Output is correct |
30 |
Correct |
9 ms |
78668 KB |
Output is correct |
31 |
Correct |
10 ms |
78684 KB |
Output is correct |
32 |
Correct |
9 ms |
78684 KB |
Output is correct |
33 |
Correct |
9 ms |
78684 KB |
Output is correct |
34 |
Correct |
8 ms |
78620 KB |
Output is correct |
35 |
Correct |
10 ms |
78684 KB |
Output is correct |
36 |
Correct |
10 ms |
78564 KB |
Output is correct |
37 |
Correct |
9 ms |
78736 KB |
Output is correct |
38 |
Correct |
10 ms |
78680 KB |
Output is correct |
39 |
Correct |
9 ms |
78664 KB |
Output is correct |
40 |
Correct |
9 ms |
78684 KB |
Output is correct |
41 |
Correct |
9 ms |
78692 KB |
Output is correct |
42 |
Correct |
10 ms |
78684 KB |
Output is correct |
43 |
Correct |
9 ms |
78668 KB |
Output is correct |
44 |
Correct |
9 ms |
78684 KB |
Output is correct |
45 |
Correct |
10 ms |
78624 KB |
Output is correct |
46 |
Correct |
10 ms |
78712 KB |
Output is correct |
47 |
Correct |
9 ms |
78684 KB |
Output is correct |
48 |
Correct |
10 ms |
78684 KB |
Output is correct |
49 |
Correct |
10 ms |
78704 KB |
Output is correct |
50 |
Correct |
10 ms |
78680 KB |
Output is correct |
51 |
Correct |
11 ms |
78684 KB |
Output is correct |
52 |
Correct |
10 ms |
78712 KB |
Output is correct |
53 |
Correct |
10 ms |
78684 KB |
Output is correct |
54 |
Correct |
9 ms |
78544 KB |
Output is correct |
55 |
Correct |
9 ms |
78684 KB |
Output is correct |
56 |
Correct |
10 ms |
78712 KB |
Output is correct |
57 |
Correct |
10 ms |
78624 KB |
Output is correct |
58 |
Correct |
10 ms |
78684 KB |
Output is correct |
59 |
Correct |
9 ms |
78684 KB |
Output is correct |
60 |
Correct |
9 ms |
78612 KB |
Output is correct |
61 |
Correct |
9 ms |
78592 KB |
Output is correct |
62 |
Correct |
9 ms |
78684 KB |
Output is correct |
63 |
Correct |
9 ms |
78600 KB |
Output is correct |
64 |
Correct |
10 ms |
78684 KB |
Output is correct |
65 |
Correct |
9 ms |
78684 KB |
Output is correct |
66 |
Correct |
9 ms |
78684 KB |
Output is correct |
67 |
Correct |
10 ms |
78584 KB |
Output is correct |
68 |
Correct |
10 ms |
78744 KB |
Output is correct |
69 |
Correct |
10 ms |
78684 KB |
Output is correct |
70 |
Correct |
10 ms |
78684 KB |
Output is correct |
71 |
Correct |
9 ms |
78704 KB |
Output is correct |
72 |
Correct |
10 ms |
78680 KB |
Output is correct |
73 |
Correct |
9 ms |
78684 KB |
Output is correct |
74 |
Correct |
9 ms |
78680 KB |
Output is correct |
75 |
Correct |
9 ms |
78720 KB |
Output is correct |
76 |
Correct |
9 ms |
78824 KB |
Output is correct |
77 |
Correct |
9 ms |
78684 KB |
Output is correct |
78 |
Correct |
9 ms |
78684 KB |
Output is correct |
79 |
Correct |
9 ms |
78572 KB |
Output is correct |
80 |
Correct |
9 ms |
78684 KB |
Output is correct |
81 |
Correct |
10 ms |
78684 KB |
Output is correct |
82 |
Correct |
10 ms |
78684 KB |
Output is correct |
83 |
Correct |
10 ms |
78612 KB |
Output is correct |
84 |
Correct |
10 ms |
78684 KB |
Output is correct |
85 |
Correct |
9 ms |
78684 KB |
Output is correct |
86 |
Correct |
9 ms |
78684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
78680 KB |
Output is correct |
2 |
Correct |
10 ms |
78684 KB |
Output is correct |
3 |
Correct |
10 ms |
78576 KB |
Output is correct |
4 |
Correct |
9 ms |
78680 KB |
Output is correct |
5 |
Correct |
10 ms |
78684 KB |
Output is correct |
6 |
Correct |
10 ms |
78712 KB |
Output is correct |
7 |
Correct |
10 ms |
78680 KB |
Output is correct |
8 |
Correct |
10 ms |
78688 KB |
Output is correct |
9 |
Correct |
9 ms |
78736 KB |
Output is correct |
10 |
Correct |
10 ms |
78684 KB |
Output is correct |
11 |
Correct |
9 ms |
78680 KB |
Output is correct |
12 |
Correct |
9 ms |
78696 KB |
Output is correct |
13 |
Correct |
9 ms |
78684 KB |
Output is correct |
14 |
Correct |
10 ms |
78540 KB |
Output is correct |
15 |
Correct |
10 ms |
78684 KB |
Output is correct |
16 |
Correct |
10 ms |
78556 KB |
Output is correct |
17 |
Correct |
10 ms |
78684 KB |
Output is correct |
18 |
Correct |
12 ms |
78684 KB |
Output is correct |
19 |
Correct |
10 ms |
78612 KB |
Output is correct |
20 |
Correct |
10 ms |
78680 KB |
Output is correct |
21 |
Correct |
10 ms |
78708 KB |
Output is correct |
22 |
Correct |
10 ms |
78684 KB |
Output is correct |
23 |
Correct |
10 ms |
78684 KB |
Output is correct |
24 |
Correct |
9 ms |
78688 KB |
Output is correct |
25 |
Correct |
9 ms |
78684 KB |
Output is correct |
26 |
Correct |
10 ms |
78684 KB |
Output is correct |
27 |
Correct |
10 ms |
78684 KB |
Output is correct |
28 |
Correct |
10 ms |
78640 KB |
Output is correct |
29 |
Correct |
10 ms |
78700 KB |
Output is correct |
30 |
Correct |
9 ms |
78668 KB |
Output is correct |
31 |
Correct |
10 ms |
78684 KB |
Output is correct |
32 |
Correct |
9 ms |
78684 KB |
Output is correct |
33 |
Correct |
9 ms |
78684 KB |
Output is correct |
34 |
Correct |
8 ms |
78620 KB |
Output is correct |
35 |
Correct |
10 ms |
78684 KB |
Output is correct |
36 |
Correct |
10 ms |
78564 KB |
Output is correct |
37 |
Correct |
9 ms |
78736 KB |
Output is correct |
38 |
Correct |
10 ms |
78680 KB |
Output is correct |
39 |
Correct |
9 ms |
78664 KB |
Output is correct |
40 |
Correct |
9 ms |
78684 KB |
Output is correct |
41 |
Correct |
9 ms |
78692 KB |
Output is correct |
42 |
Correct |
10 ms |
78684 KB |
Output is correct |
43 |
Correct |
9 ms |
78668 KB |
Output is correct |
44 |
Correct |
9 ms |
78684 KB |
Output is correct |
45 |
Correct |
10 ms |
78624 KB |
Output is correct |
46 |
Correct |
10 ms |
78712 KB |
Output is correct |
47 |
Correct |
9 ms |
78684 KB |
Output is correct |
48 |
Correct |
10 ms |
78684 KB |
Output is correct |
49 |
Correct |
10 ms |
78704 KB |
Output is correct |
50 |
Correct |
10 ms |
78680 KB |
Output is correct |
51 |
Correct |
11 ms |
78684 KB |
Output is correct |
52 |
Correct |
10 ms |
78712 KB |
Output is correct |
53 |
Correct |
10 ms |
78684 KB |
Output is correct |
54 |
Correct |
9 ms |
78544 KB |
Output is correct |
55 |
Correct |
9 ms |
78684 KB |
Output is correct |
56 |
Correct |
10 ms |
78712 KB |
Output is correct |
57 |
Correct |
140 ms |
206240 KB |
Output is correct |
58 |
Correct |
174 ms |
206136 KB |
Output is correct |
59 |
Correct |
142 ms |
207056 KB |
Output is correct |
60 |
Correct |
143 ms |
206508 KB |
Output is correct |
61 |
Correct |
144 ms |
206200 KB |
Output is correct |
62 |
Correct |
133 ms |
206540 KB |
Output is correct |
63 |
Correct |
135 ms |
206540 KB |
Output is correct |
64 |
Correct |
132 ms |
206796 KB |
Output is correct |
65 |
Correct |
138 ms |
207052 KB |
Output is correct |
66 |
Correct |
136 ms |
206096 KB |
Output is correct |
67 |
Correct |
135 ms |
207060 KB |
Output is correct |
68 |
Correct |
128 ms |
206540 KB |
Output is correct |
69 |
Correct |
10 ms |
78704 KB |
Output is correct |
70 |
Correct |
10 ms |
78624 KB |
Output is correct |
71 |
Correct |
10 ms |
78684 KB |
Output is correct |
72 |
Correct |
9 ms |
78684 KB |
Output is correct |
73 |
Correct |
9 ms |
78612 KB |
Output is correct |
74 |
Correct |
9 ms |
78592 KB |
Output is correct |
75 |
Correct |
9 ms |
78684 KB |
Output is correct |
76 |
Correct |
9 ms |
78600 KB |
Output is correct |
77 |
Correct |
10 ms |
78684 KB |
Output is correct |
78 |
Correct |
9 ms |
78684 KB |
Output is correct |
79 |
Correct |
9 ms |
78684 KB |
Output is correct |
80 |
Correct |
10 ms |
78584 KB |
Output is correct |
81 |
Correct |
10 ms |
78744 KB |
Output is correct |
82 |
Correct |
10 ms |
78684 KB |
Output is correct |
83 |
Correct |
10 ms |
78684 KB |
Output is correct |
84 |
Correct |
9 ms |
78704 KB |
Output is correct |
85 |
Correct |
10 ms |
78680 KB |
Output is correct |
86 |
Correct |
9 ms |
78684 KB |
Output is correct |
87 |
Correct |
9 ms |
78680 KB |
Output is correct |
88 |
Correct |
9 ms |
78720 KB |
Output is correct |
89 |
Correct |
9 ms |
78824 KB |
Output is correct |
90 |
Correct |
9 ms |
78684 KB |
Output is correct |
91 |
Correct |
9 ms |
78684 KB |
Output is correct |
92 |
Correct |
9 ms |
78572 KB |
Output is correct |
93 |
Correct |
9 ms |
78684 KB |
Output is correct |
94 |
Correct |
10 ms |
78684 KB |
Output is correct |
95 |
Correct |
10 ms |
78684 KB |
Output is correct |
96 |
Correct |
10 ms |
78612 KB |
Output is correct |
97 |
Correct |
10 ms |
78684 KB |
Output is correct |
98 |
Correct |
9 ms |
78684 KB |
Output is correct |
99 |
Correct |
9 ms |
78684 KB |
Output is correct |
100 |
Correct |
58 ms |
92976 KB |
Output is correct |
101 |
Correct |
60 ms |
93728 KB |
Output is correct |
102 |
Correct |
55 ms |
92364 KB |
Output is correct |
103 |
Correct |
51 ms |
93240 KB |
Output is correct |
104 |
Correct |
52 ms |
92416 KB |
Output is correct |
105 |
Correct |
88 ms |
130684 KB |
Output is correct |
106 |
Correct |
83 ms |
131524 KB |
Output is correct |
107 |
Correct |
87 ms |
130604 KB |
Output is correct |
108 |
Correct |
80 ms |
130252 KB |
Output is correct |
109 |
Correct |
95 ms |
131280 KB |
Output is correct |
110 |
Correct |
62 ms |
92880 KB |
Output is correct |
111 |
Correct |
59 ms |
92624 KB |
Output is correct |
112 |
Correct |
61 ms |
92372 KB |
Output is correct |
113 |
Correct |
60 ms |
93320 KB |
Output is correct |
114 |
Correct |
60 ms |
92628 KB |
Output is correct |
115 |
Correct |
138 ms |
206268 KB |
Output is correct |
116 |
Correct |
135 ms |
206088 KB |
Output is correct |
117 |
Correct |
136 ms |
206544 KB |
Output is correct |
118 |
Correct |
134 ms |
206284 KB |
Output is correct |
119 |
Correct |
144 ms |
206052 KB |
Output is correct |
120 |
Correct |
54 ms |
92628 KB |
Output is correct |
121 |
Correct |
59 ms |
93652 KB |
Output is correct |
122 |
Correct |
60 ms |
93256 KB |
Output is correct |
123 |
Correct |
60 ms |
92880 KB |
Output is correct |
124 |
Correct |
87 ms |
149968 KB |
Output is correct |
125 |
Correct |
85 ms |
149084 KB |
Output is correct |
126 |
Correct |
86 ms |
149708 KB |
Output is correct |
127 |
Correct |
84 ms |
150176 KB |
Output is correct |
128 |
Correct |
29 ms |
85980 KB |
Output is correct |
129 |
Correct |
28 ms |
85972 KB |
Output is correct |
130 |
Correct |
30 ms |
86000 KB |
Output is correct |
131 |
Correct |
9 ms |
78720 KB |
Output is correct |