# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
839176 | 2023-08-29T01:34:58 Z | dolphingarlic | Homework (CEOI22_homework) | C++17 | 271 ms | 177680 KB |
#include <bits/stdc++.h> using namespace std;const int N=3e6;vector<int>g[N];int p[N],n=0,t[N],sz[N],mn[N],mx[N];void dfs(int z=1){if(!g[z].size())return;int u=g[z][0],v=g[z][1];dfs(u);dfs(v);sz[z]+=sz[u]+sz[v];if(t[z]==1){mn[z]=min(mn[u],mn[v]);mx[z]=mx[u]+mx[v]-1;}else if(t[z]==2){mn[z]=mn[u]+mn[v];mx[z]=max(sz[u]+mx[v],sz[v]+mx[u]);}}main(){string s;cin >> s;int c=0;for(int i=0;i<s.size();i++){if(s[i]=='m'){p[++n]=c;g[c].push_back(n);c=n;if(s[i+2]=='n')t[c]=1;else t[c]=2;i+=3;}else if(s[i]=='?'){p[++n]=c;g[c].push_back(n);c=n;mn[c]=mx[c]=sz[c]=1;}else c=p[c];}dfs();cout<<mx[1]-mn[1]+1;return 0;}
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 70776 KB | Output is correct |
2 | Correct | 32 ms | 70704 KB | Output is correct |
3 | Correct | 34 ms | 70740 KB | Output is correct |
4 | Correct | 31 ms | 70744 KB | Output is correct |
5 | Correct | 32 ms | 70788 KB | Output is correct |
6 | Correct | 33 ms | 70684 KB | Output is correct |
7 | Correct | 31 ms | 70732 KB | Output is correct |
8 | Correct | 30 ms | 70708 KB | Output is correct |
9 | Correct | 32 ms | 70740 KB | Output is correct |
10 | Correct | 32 ms | 70668 KB | Output is correct |
11 | Correct | 35 ms | 70744 KB | Output is correct |
12 | Correct | 33 ms | 70684 KB | Output is correct |
13 | Correct | 32 ms | 70740 KB | Output is correct |
14 | Correct | 34 ms | 70692 KB | Output is correct |
15 | Correct | 32 ms | 70780 KB | Output is correct |
16 | Correct | 33 ms | 70772 KB | Output is correct |
17 | Correct | 32 ms | 70788 KB | Output is correct |
18 | Correct | 32 ms | 70720 KB | Output is correct |
19 | Correct | 32 ms | 70676 KB | Output is correct |
20 | Correct | 31 ms | 70740 KB | Output is correct |
21 | Correct | 32 ms | 70680 KB | Output is correct |
22 | Correct | 32 ms | 70796 KB | Output is correct |
23 | Correct | 32 ms | 70732 KB | Output is correct |
24 | Correct | 33 ms | 70740 KB | Output is correct |
25 | Correct | 31 ms | 70732 KB | Output is correct |
26 | Correct | 32 ms | 70736 KB | Output is correct |
27 | Correct | 33 ms | 70780 KB | Output is correct |
28 | Correct | 37 ms | 70768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 70776 KB | Output is correct |
2 | Correct | 32 ms | 70704 KB | Output is correct |
3 | Correct | 34 ms | 70740 KB | Output is correct |
4 | Correct | 31 ms | 70744 KB | Output is correct |
5 | Correct | 32 ms | 70788 KB | Output is correct |
6 | Correct | 33 ms | 70684 KB | Output is correct |
7 | Correct | 31 ms | 70732 KB | Output is correct |
8 | Correct | 30 ms | 70708 KB | Output is correct |
9 | Correct | 32 ms | 70740 KB | Output is correct |
10 | Correct | 32 ms | 70668 KB | Output is correct |
11 | Correct | 35 ms | 70744 KB | Output is correct |
12 | Correct | 33 ms | 70684 KB | Output is correct |
13 | Correct | 32 ms | 70740 KB | Output is correct |
14 | Correct | 34 ms | 70692 KB | Output is correct |
15 | Correct | 32 ms | 70780 KB | Output is correct |
16 | Correct | 33 ms | 70772 KB | Output is correct |
17 | Correct | 32 ms | 70788 KB | Output is correct |
18 | Correct | 32 ms | 70720 KB | Output is correct |
19 | Correct | 32 ms | 70676 KB | Output is correct |
20 | Correct | 31 ms | 70740 KB | Output is correct |
21 | Correct | 32 ms | 70680 KB | Output is correct |
22 | Correct | 32 ms | 70796 KB | Output is correct |
23 | Correct | 32 ms | 70732 KB | Output is correct |
24 | Correct | 33 ms | 70740 KB | Output is correct |
25 | Correct | 31 ms | 70732 KB | Output is correct |
26 | Correct | 32 ms | 70736 KB | Output is correct |
27 | Correct | 33 ms | 70780 KB | Output is correct |
28 | Correct | 37 ms | 70768 KB | Output is correct |
29 | Correct | 32 ms | 70760 KB | Output is correct |
30 | Correct | 32 ms | 70784 KB | Output is correct |
31 | Correct | 33 ms | 70772 KB | Output is correct |
32 | Correct | 40 ms | 70740 KB | Output is correct |
33 | Correct | 33 ms | 70768 KB | Output is correct |
34 | Correct | 43 ms | 70716 KB | Output is correct |
35 | Correct | 33 ms | 70660 KB | Output is correct |
36 | Correct | 32 ms | 70800 KB | Output is correct |
37 | Correct | 33 ms | 70784 KB | Output is correct |
38 | Correct | 33 ms | 70772 KB | Output is correct |
39 | Correct | 33 ms | 70732 KB | Output is correct |
40 | Correct | 33 ms | 70764 KB | Output is correct |
41 | Correct | 32 ms | 70792 KB | Output is correct |
42 | Correct | 32 ms | 70740 KB | Output is correct |
43 | Correct | 33 ms | 70776 KB | Output is correct |
44 | Correct | 33 ms | 70784 KB | Output is correct |
45 | Correct | 35 ms | 70720 KB | Output is correct |
46 | Correct | 34 ms | 70744 KB | Output is correct |
47 | Correct | 34 ms | 70780 KB | Output is correct |
48 | Correct | 38 ms | 70728 KB | Output is correct |
49 | Correct | 34 ms | 70732 KB | Output is correct |
50 | Correct | 33 ms | 70728 KB | Output is correct |
51 | Correct | 33 ms | 70740 KB | Output is correct |
52 | Correct | 33 ms | 70688 KB | Output is correct |
53 | Correct | 33 ms | 70740 KB | Output is correct |
54 | Correct | 33 ms | 70740 KB | Output is correct |
55 | Correct | 32 ms | 70772 KB | Output is correct |
56 | Correct | 33 ms | 70768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 250 ms | 177308 KB | Output is correct |
2 | Correct | 255 ms | 177448 KB | Output is correct |
3 | Correct | 248 ms | 177332 KB | Output is correct |
4 | Correct | 253 ms | 177432 KB | Output is correct |
5 | Correct | 249 ms | 177416 KB | Output is correct |
6 | Correct | 244 ms | 177312 KB | Output is correct |
7 | Correct | 247 ms | 177360 KB | Output is correct |
8 | Correct | 245 ms | 177400 KB | Output is correct |
9 | Correct | 247 ms | 177424 KB | Output is correct |
10 | Correct | 250 ms | 177680 KB | Output is correct |
11 | Correct | 245 ms | 177320 KB | Output is correct |
12 | Correct | 253 ms | 177376 KB | Output is correct |
13 | Correct | 36 ms | 70768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 70776 KB | Output is correct |
2 | Correct | 32 ms | 70704 KB | Output is correct |
3 | Correct | 34 ms | 70740 KB | Output is correct |
4 | Correct | 31 ms | 70744 KB | Output is correct |
5 | Correct | 32 ms | 70788 KB | Output is correct |
6 | Correct | 33 ms | 70684 KB | Output is correct |
7 | Correct | 31 ms | 70732 KB | Output is correct |
8 | Correct | 30 ms | 70708 KB | Output is correct |
9 | Correct | 32 ms | 70740 KB | Output is correct |
10 | Correct | 32 ms | 70668 KB | Output is correct |
11 | Correct | 35 ms | 70744 KB | Output is correct |
12 | Correct | 33 ms | 70684 KB | Output is correct |
13 | Correct | 32 ms | 70740 KB | Output is correct |
14 | Correct | 34 ms | 70692 KB | Output is correct |
15 | Correct | 32 ms | 70780 KB | Output is correct |
16 | Correct | 33 ms | 70772 KB | Output is correct |
17 | Correct | 32 ms | 70788 KB | Output is correct |
18 | Correct | 32 ms | 70720 KB | Output is correct |
19 | Correct | 32 ms | 70676 KB | Output is correct |
20 | Correct | 31 ms | 70740 KB | Output is correct |
21 | Correct | 32 ms | 70680 KB | Output is correct |
22 | Correct | 32 ms | 70796 KB | Output is correct |
23 | Correct | 32 ms | 70732 KB | Output is correct |
24 | Correct | 33 ms | 70740 KB | Output is correct |
25 | Correct | 31 ms | 70732 KB | Output is correct |
26 | Correct | 32 ms | 70736 KB | Output is correct |
27 | Correct | 33 ms | 70780 KB | Output is correct |
28 | Correct | 37 ms | 70768 KB | Output is correct |
29 | Correct | 32 ms | 70760 KB | Output is correct |
30 | Correct | 32 ms | 70784 KB | Output is correct |
31 | Correct | 33 ms | 70772 KB | Output is correct |
32 | Correct | 40 ms | 70740 KB | Output is correct |
33 | Correct | 33 ms | 70768 KB | Output is correct |
34 | Correct | 43 ms | 70716 KB | Output is correct |
35 | Correct | 33 ms | 70660 KB | Output is correct |
36 | Correct | 32 ms | 70800 KB | Output is correct |
37 | Correct | 33 ms | 70784 KB | Output is correct |
38 | Correct | 33 ms | 70772 KB | Output is correct |
39 | Correct | 33 ms | 70732 KB | Output is correct |
40 | Correct | 33 ms | 70764 KB | Output is correct |
41 | Correct | 32 ms | 70792 KB | Output is correct |
42 | Correct | 32 ms | 70740 KB | Output is correct |
43 | Correct | 33 ms | 70776 KB | Output is correct |
44 | Correct | 33 ms | 70784 KB | Output is correct |
45 | Correct | 35 ms | 70720 KB | Output is correct |
46 | Correct | 34 ms | 70744 KB | Output is correct |
47 | Correct | 34 ms | 70780 KB | Output is correct |
48 | Correct | 38 ms | 70728 KB | Output is correct |
49 | Correct | 34 ms | 70732 KB | Output is correct |
50 | Correct | 33 ms | 70728 KB | Output is correct |
51 | Correct | 33 ms | 70740 KB | Output is correct |
52 | Correct | 33 ms | 70688 KB | Output is correct |
53 | Correct | 33 ms | 70740 KB | Output is correct |
54 | Correct | 33 ms | 70740 KB | Output is correct |
55 | Correct | 32 ms | 70772 KB | Output is correct |
56 | Correct | 33 ms | 70768 KB | Output is correct |
57 | Correct | 37 ms | 70868 KB | Output is correct |
58 | Correct | 32 ms | 70740 KB | Output is correct |
59 | Correct | 34 ms | 70732 KB | Output is correct |
60 | Correct | 33 ms | 70780 KB | Output is correct |
61 | Correct | 34 ms | 70740 KB | Output is correct |
62 | Correct | 35 ms | 70796 KB | Output is correct |
63 | Correct | 33 ms | 70868 KB | Output is correct |
64 | Correct | 33 ms | 70760 KB | Output is correct |
65 | Correct | 33 ms | 70868 KB | Output is correct |
66 | Correct | 33 ms | 70808 KB | Output is correct |
67 | Correct | 33 ms | 70804 KB | Output is correct |
68 | Correct | 38 ms | 70732 KB | Output is correct |
69 | Correct | 33 ms | 70764 KB | Output is correct |
70 | Correct | 33 ms | 70852 KB | Output is correct |
71 | Correct | 33 ms | 70848 KB | Output is correct |
72 | Correct | 36 ms | 70844 KB | Output is correct |
73 | Correct | 34 ms | 70880 KB | Output is correct |
74 | Correct | 34 ms | 70840 KB | Output is correct |
75 | Correct | 33 ms | 70844 KB | Output is correct |
76 | Correct | 34 ms | 70792 KB | Output is correct |
77 | Correct | 34 ms | 70740 KB | Output is correct |
78 | Correct | 33 ms | 70848 KB | Output is correct |
79 | Correct | 34 ms | 70740 KB | Output is correct |
80 | Correct | 36 ms | 70848 KB | Output is correct |
81 | Correct | 33 ms | 70772 KB | Output is correct |
82 | Correct | 33 ms | 70744 KB | Output is correct |
83 | Correct | 32 ms | 70784 KB | Output is correct |
84 | Correct | 34 ms | 70740 KB | Output is correct |
85 | Correct | 33 ms | 70796 KB | Output is correct |
86 | Correct | 33 ms | 70728 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 70776 KB | Output is correct |
2 | Correct | 32 ms | 70704 KB | Output is correct |
3 | Correct | 34 ms | 70740 KB | Output is correct |
4 | Correct | 31 ms | 70744 KB | Output is correct |
5 | Correct | 32 ms | 70788 KB | Output is correct |
6 | Correct | 33 ms | 70684 KB | Output is correct |
7 | Correct | 31 ms | 70732 KB | Output is correct |
8 | Correct | 30 ms | 70708 KB | Output is correct |
9 | Correct | 32 ms | 70740 KB | Output is correct |
10 | Correct | 32 ms | 70668 KB | Output is correct |
11 | Correct | 35 ms | 70744 KB | Output is correct |
12 | Correct | 33 ms | 70684 KB | Output is correct |
13 | Correct | 32 ms | 70740 KB | Output is correct |
14 | Correct | 34 ms | 70692 KB | Output is correct |
15 | Correct | 32 ms | 70780 KB | Output is correct |
16 | Correct | 33 ms | 70772 KB | Output is correct |
17 | Correct | 32 ms | 70788 KB | Output is correct |
18 | Correct | 32 ms | 70720 KB | Output is correct |
19 | Correct | 32 ms | 70676 KB | Output is correct |
20 | Correct | 31 ms | 70740 KB | Output is correct |
21 | Correct | 32 ms | 70680 KB | Output is correct |
22 | Correct | 32 ms | 70796 KB | Output is correct |
23 | Correct | 32 ms | 70732 KB | Output is correct |
24 | Correct | 33 ms | 70740 KB | Output is correct |
25 | Correct | 31 ms | 70732 KB | Output is correct |
26 | Correct | 32 ms | 70736 KB | Output is correct |
27 | Correct | 33 ms | 70780 KB | Output is correct |
28 | Correct | 37 ms | 70768 KB | Output is correct |
29 | Correct | 32 ms | 70760 KB | Output is correct |
30 | Correct | 32 ms | 70784 KB | Output is correct |
31 | Correct | 33 ms | 70772 KB | Output is correct |
32 | Correct | 40 ms | 70740 KB | Output is correct |
33 | Correct | 33 ms | 70768 KB | Output is correct |
34 | Correct | 43 ms | 70716 KB | Output is correct |
35 | Correct | 33 ms | 70660 KB | Output is correct |
36 | Correct | 32 ms | 70800 KB | Output is correct |
37 | Correct | 33 ms | 70784 KB | Output is correct |
38 | Correct | 33 ms | 70772 KB | Output is correct |
39 | Correct | 33 ms | 70732 KB | Output is correct |
40 | Correct | 33 ms | 70764 KB | Output is correct |
41 | Correct | 32 ms | 70792 KB | Output is correct |
42 | Correct | 32 ms | 70740 KB | Output is correct |
43 | Correct | 33 ms | 70776 KB | Output is correct |
44 | Correct | 33 ms | 70784 KB | Output is correct |
45 | Correct | 35 ms | 70720 KB | Output is correct |
46 | Correct | 34 ms | 70744 KB | Output is correct |
47 | Correct | 34 ms | 70780 KB | Output is correct |
48 | Correct | 38 ms | 70728 KB | Output is correct |
49 | Correct | 34 ms | 70732 KB | Output is correct |
50 | Correct | 33 ms | 70728 KB | Output is correct |
51 | Correct | 33 ms | 70740 KB | Output is correct |
52 | Correct | 33 ms | 70688 KB | Output is correct |
53 | Correct | 33 ms | 70740 KB | Output is correct |
54 | Correct | 33 ms | 70740 KB | Output is correct |
55 | Correct | 32 ms | 70772 KB | Output is correct |
56 | Correct | 33 ms | 70768 KB | Output is correct |
57 | Correct | 250 ms | 177308 KB | Output is correct |
58 | Correct | 255 ms | 177448 KB | Output is correct |
59 | Correct | 248 ms | 177332 KB | Output is correct |
60 | Correct | 253 ms | 177432 KB | Output is correct |
61 | Correct | 249 ms | 177416 KB | Output is correct |
62 | Correct | 244 ms | 177312 KB | Output is correct |
63 | Correct | 247 ms | 177360 KB | Output is correct |
64 | Correct | 245 ms | 177400 KB | Output is correct |
65 | Correct | 247 ms | 177424 KB | Output is correct |
66 | Correct | 250 ms | 177680 KB | Output is correct |
67 | Correct | 245 ms | 177320 KB | Output is correct |
68 | Correct | 253 ms | 177376 KB | Output is correct |
69 | Correct | 36 ms | 70768 KB | Output is correct |
70 | Correct | 37 ms | 70868 KB | Output is correct |
71 | Correct | 32 ms | 70740 KB | Output is correct |
72 | Correct | 34 ms | 70732 KB | Output is correct |
73 | Correct | 33 ms | 70780 KB | Output is correct |
74 | Correct | 34 ms | 70740 KB | Output is correct |
75 | Correct | 35 ms | 70796 KB | Output is correct |
76 | Correct | 33 ms | 70868 KB | Output is correct |
77 | Correct | 33 ms | 70760 KB | Output is correct |
78 | Correct | 33 ms | 70868 KB | Output is correct |
79 | Correct | 33 ms | 70808 KB | Output is correct |
80 | Correct | 33 ms | 70804 KB | Output is correct |
81 | Correct | 38 ms | 70732 KB | Output is correct |
82 | Correct | 33 ms | 70764 KB | Output is correct |
83 | Correct | 33 ms | 70852 KB | Output is correct |
84 | Correct | 33 ms | 70848 KB | Output is correct |
85 | Correct | 36 ms | 70844 KB | Output is correct |
86 | Correct | 34 ms | 70880 KB | Output is correct |
87 | Correct | 34 ms | 70840 KB | Output is correct |
88 | Correct | 33 ms | 70844 KB | Output is correct |
89 | Correct | 34 ms | 70792 KB | Output is correct |
90 | Correct | 34 ms | 70740 KB | Output is correct |
91 | Correct | 33 ms | 70848 KB | Output is correct |
92 | Correct | 34 ms | 70740 KB | Output is correct |
93 | Correct | 36 ms | 70848 KB | Output is correct |
94 | Correct | 33 ms | 70772 KB | Output is correct |
95 | Correct | 33 ms | 70744 KB | Output is correct |
96 | Correct | 32 ms | 70784 KB | Output is correct |
97 | Correct | 34 ms | 70740 KB | Output is correct |
98 | Correct | 33 ms | 70796 KB | Output is correct |
99 | Correct | 33 ms | 70728 KB | Output is correct |
100 | Correct | 228 ms | 148076 KB | Output is correct |
101 | Correct | 246 ms | 148012 KB | Output is correct |
102 | Correct | 226 ms | 148024 KB | Output is correct |
103 | Correct | 226 ms | 147964 KB | Output is correct |
104 | Correct | 229 ms | 148008 KB | Output is correct |
105 | Correct | 245 ms | 158400 KB | Output is correct |
106 | Correct | 271 ms | 158400 KB | Output is correct |
107 | Correct | 242 ms | 158400 KB | Output is correct |
108 | Correct | 241 ms | 158592 KB | Output is correct |
109 | Correct | 242 ms | 158444 KB | Output is correct |
110 | Correct | 261 ms | 147956 KB | Output is correct |
111 | Correct | 233 ms | 148084 KB | Output is correct |
112 | Correct | 235 ms | 148000 KB | Output is correct |
113 | Correct | 232 ms | 147992 KB | Output is correct |
114 | Correct | 236 ms | 148056 KB | Output is correct |
115 | Correct | 250 ms | 177428 KB | Output is correct |
116 | Correct | 247 ms | 177340 KB | Output is correct |
117 | Correct | 250 ms | 177404 KB | Output is correct |
118 | Correct | 249 ms | 177328 KB | Output is correct |
119 | Correct | 247 ms | 177324 KB | Output is correct |
120 | Correct | 230 ms | 148036 KB | Output is correct |
121 | Correct | 232 ms | 148116 KB | Output is correct |
122 | Correct | 242 ms | 148080 KB | Output is correct |
123 | Correct | 234 ms | 147996 KB | Output is correct |
124 | Correct | 250 ms | 163712 KB | Output is correct |
125 | Correct | 234 ms | 163728 KB | Output is correct |
126 | Correct | 232 ms | 163720 KB | Output is correct |
127 | Correct | 253 ms | 163736 KB | Output is correct |
128 | Correct | 129 ms | 111204 KB | Output is correct |
129 | Correct | 137 ms | 111264 KB | Output is correct |
130 | Correct | 128 ms | 111252 KB | Output is correct |
131 | Correct | 33 ms | 70740 KB | Output is correct |