답안 #731203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
731203 2023-04-27T07:03:28 Z baokhue232005 Homework (CEOI22_homework) C++14
100 / 100
434 ms 165732 KB
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
// lethal option

#include<bits/stdc++.h>
using namespace std;

#define all(flg) flg.begin(), flg.end()
#define int long long
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define eb emplace_back
#define ii pair<int, int>
#define vi vector<int>
#define PI 3.141592653589793238462643383279502884
#define ll long long
#define ld long double
#define for1(i, ff, gg) for(int i = ff; i <= gg; ++i)
#define for2(i, ff, gg) for(int i = ff; i >= gg; --i)
const ll mod = 1e9 + 7;
const int maxN = 2e6 + 5;
const ll oo = 1e18 + 7;
int n = 0, a[maxN];
int x, y, z, k;

vi vc[maxN];
bool tag[maxN];

int dfs_build(){
    int node = ++z;
    char c; cin >> c; if(c == '?'){
        ++n; return node;
    }
    cin >> c >> c;
    tag[node] = (c == 'n');
    cin >> c; vc[node].pb(dfs_build());
    cin >> c; vc[node].pb(dfs_build());
    cin >> c;
    return node;
}

int dfs_calc(int node){
    if(vc[node].empty()) return 1;
    int v1 = dfs_calc(vc[node][0]);
    int v2 = dfs_calc(vc[node][1]);
    if(tag[node]) return v1 + v2;
    else return min(v1, v2);
}

signed main(){
    // freopen(".inp", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    z = 0; dfs_build();
    int ans = n + 2;
    ans -= dfs_calc(1);
    for1(i, 1, z) tag[i] = !tag[i];
    ans -= dfs_calc(1);
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 47304 KB Output is correct
2 Correct 24 ms 47260 KB Output is correct
3 Correct 29 ms 47188 KB Output is correct
4 Correct 24 ms 47236 KB Output is correct
5 Correct 25 ms 47188 KB Output is correct
6 Correct 25 ms 47228 KB Output is correct
7 Correct 25 ms 47188 KB Output is correct
8 Correct 25 ms 47248 KB Output is correct
9 Correct 26 ms 47204 KB Output is correct
10 Correct 26 ms 47284 KB Output is correct
11 Correct 24 ms 47188 KB Output is correct
12 Correct 24 ms 47176 KB Output is correct
13 Correct 24 ms 47304 KB Output is correct
14 Correct 25 ms 47296 KB Output is correct
15 Correct 27 ms 47288 KB Output is correct
16 Correct 27 ms 47188 KB Output is correct
17 Correct 26 ms 47212 KB Output is correct
18 Correct 26 ms 47256 KB Output is correct
19 Correct 25 ms 47288 KB Output is correct
20 Correct 25 ms 47232 KB Output is correct
21 Correct 25 ms 47188 KB Output is correct
22 Correct 25 ms 47188 KB Output is correct
23 Correct 26 ms 47224 KB Output is correct
24 Correct 25 ms 47212 KB Output is correct
25 Correct 25 ms 47276 KB Output is correct
26 Correct 26 ms 47236 KB Output is correct
27 Correct 26 ms 47236 KB Output is correct
28 Correct 25 ms 47224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 47304 KB Output is correct
2 Correct 24 ms 47260 KB Output is correct
3 Correct 29 ms 47188 KB Output is correct
4 Correct 24 ms 47236 KB Output is correct
5 Correct 25 ms 47188 KB Output is correct
6 Correct 25 ms 47228 KB Output is correct
7 Correct 25 ms 47188 KB Output is correct
8 Correct 25 ms 47248 KB Output is correct
9 Correct 26 ms 47204 KB Output is correct
10 Correct 26 ms 47284 KB Output is correct
11 Correct 24 ms 47188 KB Output is correct
12 Correct 24 ms 47176 KB Output is correct
13 Correct 24 ms 47304 KB Output is correct
14 Correct 25 ms 47296 KB Output is correct
15 Correct 27 ms 47288 KB Output is correct
16 Correct 27 ms 47188 KB Output is correct
17 Correct 26 ms 47212 KB Output is correct
18 Correct 26 ms 47256 KB Output is correct
19 Correct 25 ms 47288 KB Output is correct
20 Correct 25 ms 47232 KB Output is correct
21 Correct 25 ms 47188 KB Output is correct
22 Correct 25 ms 47188 KB Output is correct
23 Correct 26 ms 47224 KB Output is correct
24 Correct 25 ms 47212 KB Output is correct
25 Correct 25 ms 47276 KB Output is correct
26 Correct 26 ms 47236 KB Output is correct
27 Correct 26 ms 47236 KB Output is correct
28 Correct 25 ms 47224 KB Output is correct
29 Correct 29 ms 47224 KB Output is correct
30 Correct 25 ms 47188 KB Output is correct
31 Correct 25 ms 47292 KB Output is correct
32 Correct 26 ms 47292 KB Output is correct
33 Correct 27 ms 47188 KB Output is correct
34 Correct 25 ms 47184 KB Output is correct
35 Correct 25 ms 47288 KB Output is correct
36 Correct 27 ms 47292 KB Output is correct
37 Correct 28 ms 47188 KB Output is correct
38 Correct 41 ms 47180 KB Output is correct
39 Correct 26 ms 47224 KB Output is correct
40 Correct 25 ms 47272 KB Output is correct
41 Correct 25 ms 47284 KB Output is correct
42 Correct 24 ms 47188 KB Output is correct
43 Correct 26 ms 47220 KB Output is correct
44 Correct 25 ms 47188 KB Output is correct
45 Correct 26 ms 47268 KB Output is correct
46 Correct 25 ms 47184 KB Output is correct
47 Correct 25 ms 47188 KB Output is correct
48 Correct 27 ms 47180 KB Output is correct
49 Correct 27 ms 47188 KB Output is correct
50 Correct 28 ms 47316 KB Output is correct
51 Correct 25 ms 47260 KB Output is correct
52 Correct 25 ms 47288 KB Output is correct
53 Correct 25 ms 47292 KB Output is correct
54 Correct 25 ms 47308 KB Output is correct
55 Correct 26 ms 47288 KB Output is correct
56 Correct 30 ms 47188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 316 ms 165616 KB Output is correct
2 Correct 287 ms 165688 KB Output is correct
3 Correct 324 ms 165572 KB Output is correct
4 Correct 302 ms 165588 KB Output is correct
5 Correct 310 ms 165664 KB Output is correct
6 Correct 298 ms 165604 KB Output is correct
7 Correct 310 ms 165704 KB Output is correct
8 Correct 300 ms 165692 KB Output is correct
9 Correct 291 ms 165700 KB Output is correct
10 Correct 319 ms 165668 KB Output is correct
11 Correct 300 ms 165584 KB Output is correct
12 Correct 308 ms 165732 KB Output is correct
13 Correct 27 ms 47204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 47304 KB Output is correct
2 Correct 24 ms 47260 KB Output is correct
3 Correct 29 ms 47188 KB Output is correct
4 Correct 24 ms 47236 KB Output is correct
5 Correct 25 ms 47188 KB Output is correct
6 Correct 25 ms 47228 KB Output is correct
7 Correct 25 ms 47188 KB Output is correct
8 Correct 25 ms 47248 KB Output is correct
9 Correct 26 ms 47204 KB Output is correct
10 Correct 26 ms 47284 KB Output is correct
11 Correct 24 ms 47188 KB Output is correct
12 Correct 24 ms 47176 KB Output is correct
13 Correct 24 ms 47304 KB Output is correct
14 Correct 25 ms 47296 KB Output is correct
15 Correct 27 ms 47288 KB Output is correct
16 Correct 27 ms 47188 KB Output is correct
17 Correct 26 ms 47212 KB Output is correct
18 Correct 26 ms 47256 KB Output is correct
19 Correct 25 ms 47288 KB Output is correct
20 Correct 25 ms 47232 KB Output is correct
21 Correct 25 ms 47188 KB Output is correct
22 Correct 25 ms 47188 KB Output is correct
23 Correct 26 ms 47224 KB Output is correct
24 Correct 25 ms 47212 KB Output is correct
25 Correct 25 ms 47276 KB Output is correct
26 Correct 26 ms 47236 KB Output is correct
27 Correct 26 ms 47236 KB Output is correct
28 Correct 25 ms 47224 KB Output is correct
29 Correct 29 ms 47224 KB Output is correct
30 Correct 25 ms 47188 KB Output is correct
31 Correct 25 ms 47292 KB Output is correct
32 Correct 26 ms 47292 KB Output is correct
33 Correct 27 ms 47188 KB Output is correct
34 Correct 25 ms 47184 KB Output is correct
35 Correct 25 ms 47288 KB Output is correct
36 Correct 27 ms 47292 KB Output is correct
37 Correct 28 ms 47188 KB Output is correct
38 Correct 41 ms 47180 KB Output is correct
39 Correct 26 ms 47224 KB Output is correct
40 Correct 25 ms 47272 KB Output is correct
41 Correct 25 ms 47284 KB Output is correct
42 Correct 24 ms 47188 KB Output is correct
43 Correct 26 ms 47220 KB Output is correct
44 Correct 25 ms 47188 KB Output is correct
45 Correct 26 ms 47268 KB Output is correct
46 Correct 25 ms 47184 KB Output is correct
47 Correct 25 ms 47188 KB Output is correct
48 Correct 27 ms 47180 KB Output is correct
49 Correct 27 ms 47188 KB Output is correct
50 Correct 28 ms 47316 KB Output is correct
51 Correct 25 ms 47260 KB Output is correct
52 Correct 25 ms 47288 KB Output is correct
53 Correct 25 ms 47292 KB Output is correct
54 Correct 25 ms 47308 KB Output is correct
55 Correct 26 ms 47288 KB Output is correct
56 Correct 30 ms 47188 KB Output is correct
57 Correct 25 ms 47320 KB Output is correct
58 Correct 25 ms 47204 KB Output is correct
59 Correct 27 ms 47304 KB Output is correct
60 Correct 28 ms 47352 KB Output is correct
61 Correct 28 ms 47276 KB Output is correct
62 Correct 28 ms 47312 KB Output is correct
63 Correct 25 ms 47316 KB Output is correct
64 Correct 27 ms 47344 KB Output is correct
65 Correct 26 ms 47316 KB Output is correct
66 Correct 27 ms 47408 KB Output is correct
67 Correct 26 ms 47344 KB Output is correct
68 Correct 26 ms 47268 KB Output is correct
69 Correct 25 ms 47304 KB Output is correct
70 Correct 26 ms 47316 KB Output is correct
71 Correct 27 ms 47316 KB Output is correct
72 Correct 27 ms 47332 KB Output is correct
73 Correct 26 ms 47292 KB Output is correct
74 Correct 26 ms 47368 KB Output is correct
75 Correct 31 ms 47316 KB Output is correct
76 Correct 23 ms 47416 KB Output is correct
77 Correct 26 ms 47212 KB Output is correct
78 Correct 24 ms 47336 KB Output is correct
79 Correct 25 ms 47312 KB Output is correct
80 Correct 27 ms 47316 KB Output is correct
81 Correct 26 ms 47504 KB Output is correct
82 Correct 26 ms 47316 KB Output is correct
83 Correct 25 ms 47308 KB Output is correct
84 Correct 25 ms 47316 KB Output is correct
85 Correct 26 ms 47276 KB Output is correct
86 Correct 32 ms 47220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 47304 KB Output is correct
2 Correct 24 ms 47260 KB Output is correct
3 Correct 29 ms 47188 KB Output is correct
4 Correct 24 ms 47236 KB Output is correct
5 Correct 25 ms 47188 KB Output is correct
6 Correct 25 ms 47228 KB Output is correct
7 Correct 25 ms 47188 KB Output is correct
8 Correct 25 ms 47248 KB Output is correct
9 Correct 26 ms 47204 KB Output is correct
10 Correct 26 ms 47284 KB Output is correct
11 Correct 24 ms 47188 KB Output is correct
12 Correct 24 ms 47176 KB Output is correct
13 Correct 24 ms 47304 KB Output is correct
14 Correct 25 ms 47296 KB Output is correct
15 Correct 27 ms 47288 KB Output is correct
16 Correct 27 ms 47188 KB Output is correct
17 Correct 26 ms 47212 KB Output is correct
18 Correct 26 ms 47256 KB Output is correct
19 Correct 25 ms 47288 KB Output is correct
20 Correct 25 ms 47232 KB Output is correct
21 Correct 25 ms 47188 KB Output is correct
22 Correct 25 ms 47188 KB Output is correct
23 Correct 26 ms 47224 KB Output is correct
24 Correct 25 ms 47212 KB Output is correct
25 Correct 25 ms 47276 KB Output is correct
26 Correct 26 ms 47236 KB Output is correct
27 Correct 26 ms 47236 KB Output is correct
28 Correct 25 ms 47224 KB Output is correct
29 Correct 29 ms 47224 KB Output is correct
30 Correct 25 ms 47188 KB Output is correct
31 Correct 25 ms 47292 KB Output is correct
32 Correct 26 ms 47292 KB Output is correct
33 Correct 27 ms 47188 KB Output is correct
34 Correct 25 ms 47184 KB Output is correct
35 Correct 25 ms 47288 KB Output is correct
36 Correct 27 ms 47292 KB Output is correct
37 Correct 28 ms 47188 KB Output is correct
38 Correct 41 ms 47180 KB Output is correct
39 Correct 26 ms 47224 KB Output is correct
40 Correct 25 ms 47272 KB Output is correct
41 Correct 25 ms 47284 KB Output is correct
42 Correct 24 ms 47188 KB Output is correct
43 Correct 26 ms 47220 KB Output is correct
44 Correct 25 ms 47188 KB Output is correct
45 Correct 26 ms 47268 KB Output is correct
46 Correct 25 ms 47184 KB Output is correct
47 Correct 25 ms 47188 KB Output is correct
48 Correct 27 ms 47180 KB Output is correct
49 Correct 27 ms 47188 KB Output is correct
50 Correct 28 ms 47316 KB Output is correct
51 Correct 25 ms 47260 KB Output is correct
52 Correct 25 ms 47288 KB Output is correct
53 Correct 25 ms 47292 KB Output is correct
54 Correct 25 ms 47308 KB Output is correct
55 Correct 26 ms 47288 KB Output is correct
56 Correct 30 ms 47188 KB Output is correct
57 Correct 316 ms 165616 KB Output is correct
58 Correct 287 ms 165688 KB Output is correct
59 Correct 324 ms 165572 KB Output is correct
60 Correct 302 ms 165588 KB Output is correct
61 Correct 310 ms 165664 KB Output is correct
62 Correct 298 ms 165604 KB Output is correct
63 Correct 310 ms 165704 KB Output is correct
64 Correct 300 ms 165692 KB Output is correct
65 Correct 291 ms 165700 KB Output is correct
66 Correct 319 ms 165668 KB Output is correct
67 Correct 300 ms 165584 KB Output is correct
68 Correct 308 ms 165732 KB Output is correct
69 Correct 27 ms 47204 KB Output is correct
70 Correct 25 ms 47320 KB Output is correct
71 Correct 25 ms 47204 KB Output is correct
72 Correct 27 ms 47304 KB Output is correct
73 Correct 28 ms 47352 KB Output is correct
74 Correct 28 ms 47276 KB Output is correct
75 Correct 28 ms 47312 KB Output is correct
76 Correct 25 ms 47316 KB Output is correct
77 Correct 27 ms 47344 KB Output is correct
78 Correct 26 ms 47316 KB Output is correct
79 Correct 27 ms 47408 KB Output is correct
80 Correct 26 ms 47344 KB Output is correct
81 Correct 26 ms 47268 KB Output is correct
82 Correct 25 ms 47304 KB Output is correct
83 Correct 26 ms 47316 KB Output is correct
84 Correct 27 ms 47316 KB Output is correct
85 Correct 27 ms 47332 KB Output is correct
86 Correct 26 ms 47292 KB Output is correct
87 Correct 26 ms 47368 KB Output is correct
88 Correct 31 ms 47316 KB Output is correct
89 Correct 23 ms 47416 KB Output is correct
90 Correct 26 ms 47212 KB Output is correct
91 Correct 24 ms 47336 KB Output is correct
92 Correct 25 ms 47312 KB Output is correct
93 Correct 27 ms 47316 KB Output is correct
94 Correct 26 ms 47504 KB Output is correct
95 Correct 26 ms 47316 KB Output is correct
96 Correct 25 ms 47308 KB Output is correct
97 Correct 25 ms 47316 KB Output is correct
98 Correct 26 ms 47276 KB Output is correct
99 Correct 32 ms 47220 KB Output is correct
100 Correct 278 ms 87304 KB Output is correct
101 Correct 245 ms 87384 KB Output is correct
102 Correct 258 ms 87372 KB Output is correct
103 Correct 240 ms 87384 KB Output is correct
104 Correct 252 ms 87380 KB Output is correct
105 Correct 269 ms 113512 KB Output is correct
106 Correct 271 ms 113580 KB Output is correct
107 Correct 269 ms 113432 KB Output is correct
108 Correct 253 ms 113416 KB Output is correct
109 Correct 277 ms 113472 KB Output is correct
110 Correct 262 ms 87380 KB Output is correct
111 Correct 259 ms 87464 KB Output is correct
112 Correct 260 ms 87296 KB Output is correct
113 Correct 252 ms 87384 KB Output is correct
114 Correct 254 ms 87360 KB Output is correct
115 Correct 318 ms 165632 KB Output is correct
116 Correct 328 ms 165660 KB Output is correct
117 Correct 321 ms 165564 KB Output is correct
118 Correct 434 ms 165584 KB Output is correct
119 Correct 312 ms 165672 KB Output is correct
120 Correct 255 ms 87460 KB Output is correct
121 Correct 251 ms 87364 KB Output is correct
122 Correct 262 ms 87356 KB Output is correct
123 Correct 266 ms 87288 KB Output is correct
124 Correct 268 ms 126540 KB Output is correct
125 Correct 243 ms 126496 KB Output is correct
126 Correct 257 ms 126460 KB Output is correct
127 Correct 271 ms 126528 KB Output is correct
128 Correct 147 ms 68420 KB Output is correct
129 Correct 134 ms 68304 KB Output is correct
130 Correct 138 ms 68312 KB Output is correct
131 Correct 27 ms 47252 KB Output is correct