답안 #705557

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
705557 2023-03-04T15:57:32 Z krizsu222 Homework (CEOI22_homework) C++17
23 / 100
114 ms 181000 KB
#include "bits/stdc++.h"
#define TREE_SIZE (1<<20)
#define ls (v * 2)
#define rs (v * 2 + 1)
using namespace std;

struct node
{
    pair <int, int> value;
    string type;
} tree[TREE_SIZE * 2];
string s;

void insert(int v, int mx, int n)
{
    tree[v].value = {1, n};
    while(v != 0)
    {
        v /= 2;
        if(tree[v].type == "max")
        {
            //if(rs > mx) tree[v].value = tree[ls].value;
            //else tree[v].value = {max(tree[ls].value.first, tree[rs].value.first) + 1, max(tree[ls].value.second, tree[rs].value.second)};
            tree[v].value = {tree[ls].value.first + tree[rs].value.first, max(tree[ls].value.second, tree[rs].value.second)};
        }
        if(tree[v].type == "min")
        {
            //if(rs > mx) tree[v].value = tree[ls].value;
            //else tree[v].value = {min(tree[ls].value.first, tree[rs].value.first), min(tree[ls].value.second, tree[rs].value.second) - 1};
            tree[v].value = {min(tree[ls].value.first, tree[rs].value.first), tree[ls].value.second + tree[rs].value.second - n - 1};
        }
    }
}

signed main()
{
    cin.tie(0) -> ios_base::sync_with_stdio(0);
    cin >> s;
    int question_marks = count(s.begin(), s.end(), '?');
    vector <int> q;
    int mx = 0, mm = 0, it = 1, son = 0;
    for(auto u : s)
    {
        if(u == 'm' || u == 'a' || u == 'i') continue;
        if(u == '(') it *= 2;
        if(u == ')') it /= 2;
        it += son;
        int act_son = it;
        if(u == ',') son = 1;
        else son = 0;
        if(u == 'n')
        {
            tree[act_son].type = "min";
            mm++;
        }
        if(u == 'x')
        {
            tree[act_son].type = "max";
            mx++;
        }
        if(u == '?')
        {
            tree[act_son].type = "const";
            q.push_back(act_son);
        }
    }
    //for(auto u : q)
    //    cout << u << ' ';
    for(auto u : q)
        insert(u, q[q.size() - 1], question_marks);
    cout << tree[1].value.second - tree[1].value.first + 1 << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 82400 KB Output is correct
2 Correct 37 ms 82364 KB Output is correct
3 Correct 35 ms 82380 KB Output is correct
4 Correct 38 ms 82376 KB Output is correct
5 Correct 36 ms 82388 KB Output is correct
6 Correct 36 ms 82320 KB Output is correct
7 Correct 35 ms 82372 KB Output is correct
8 Correct 36 ms 82264 KB Output is correct
9 Correct 36 ms 82268 KB Output is correct
10 Correct 38 ms 82316 KB Output is correct
11 Correct 36 ms 82252 KB Output is correct
12 Correct 36 ms 82316 KB Output is correct
13 Correct 44 ms 82368 KB Output is correct
14 Correct 39 ms 82272 KB Output is correct
15 Correct 44 ms 82380 KB Output is correct
16 Correct 36 ms 82380 KB Output is correct
17 Correct 38 ms 82340 KB Output is correct
18 Correct 39 ms 82452 KB Output is correct
19 Correct 38 ms 82300 KB Output is correct
20 Correct 36 ms 82292 KB Output is correct
21 Correct 36 ms 82356 KB Output is correct
22 Correct 47 ms 82380 KB Output is correct
23 Correct 37 ms 82360 KB Output is correct
24 Correct 45 ms 82380 KB Output is correct
25 Correct 36 ms 82380 KB Output is correct
26 Correct 39 ms 82312 KB Output is correct
27 Correct 36 ms 82360 KB Output is correct
28 Correct 39 ms 82380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 82400 KB Output is correct
2 Correct 37 ms 82364 KB Output is correct
3 Correct 35 ms 82380 KB Output is correct
4 Correct 38 ms 82376 KB Output is correct
5 Correct 36 ms 82388 KB Output is correct
6 Correct 36 ms 82320 KB Output is correct
7 Correct 35 ms 82372 KB Output is correct
8 Correct 36 ms 82264 KB Output is correct
9 Correct 36 ms 82268 KB Output is correct
10 Correct 38 ms 82316 KB Output is correct
11 Correct 36 ms 82252 KB Output is correct
12 Correct 36 ms 82316 KB Output is correct
13 Correct 44 ms 82368 KB Output is correct
14 Correct 39 ms 82272 KB Output is correct
15 Correct 44 ms 82380 KB Output is correct
16 Correct 36 ms 82380 KB Output is correct
17 Correct 38 ms 82340 KB Output is correct
18 Correct 39 ms 82452 KB Output is correct
19 Correct 38 ms 82300 KB Output is correct
20 Correct 36 ms 82292 KB Output is correct
21 Correct 36 ms 82356 KB Output is correct
22 Correct 47 ms 82380 KB Output is correct
23 Correct 37 ms 82360 KB Output is correct
24 Correct 45 ms 82380 KB Output is correct
25 Correct 36 ms 82380 KB Output is correct
26 Correct 39 ms 82312 KB Output is correct
27 Correct 36 ms 82360 KB Output is correct
28 Correct 39 ms 82380 KB Output is correct
29 Correct 36 ms 82276 KB Output is correct
30 Correct 43 ms 82344 KB Output is correct
31 Correct 39 ms 82384 KB Output is correct
32 Correct 46 ms 82336 KB Output is correct
33 Correct 36 ms 82296 KB Output is correct
34 Correct 36 ms 82388 KB Output is correct
35 Correct 39 ms 82312 KB Output is correct
36 Correct 35 ms 82392 KB Output is correct
37 Correct 41 ms 82344 KB Output is correct
38 Correct 36 ms 82260 KB Output is correct
39 Correct 36 ms 82388 KB Output is correct
40 Correct 35 ms 82364 KB Output is correct
41 Correct 36 ms 82300 KB Output is correct
42 Correct 38 ms 82380 KB Output is correct
43 Correct 37 ms 82380 KB Output is correct
44 Correct 36 ms 82348 KB Output is correct
45 Correct 38 ms 82376 KB Output is correct
46 Correct 37 ms 82336 KB Output is correct
47 Correct 37 ms 82264 KB Output is correct
48 Correct 42 ms 82368 KB Output is correct
49 Correct 35 ms 82384 KB Output is correct
50 Correct 36 ms 82380 KB Output is correct
51 Correct 36 ms 82388 KB Output is correct
52 Correct 36 ms 82272 KB Output is correct
53 Correct 36 ms 82336 KB Output is correct
54 Correct 37 ms 82324 KB Output is correct
55 Correct 37 ms 82380 KB Output is correct
56 Correct 36 ms 82388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 114 ms 181000 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 82400 KB Output is correct
2 Correct 37 ms 82364 KB Output is correct
3 Correct 35 ms 82380 KB Output is correct
4 Correct 38 ms 82376 KB Output is correct
5 Correct 36 ms 82388 KB Output is correct
6 Correct 36 ms 82320 KB Output is correct
7 Correct 35 ms 82372 KB Output is correct
8 Correct 36 ms 82264 KB Output is correct
9 Correct 36 ms 82268 KB Output is correct
10 Correct 38 ms 82316 KB Output is correct
11 Correct 36 ms 82252 KB Output is correct
12 Correct 36 ms 82316 KB Output is correct
13 Correct 44 ms 82368 KB Output is correct
14 Correct 39 ms 82272 KB Output is correct
15 Correct 44 ms 82380 KB Output is correct
16 Correct 36 ms 82380 KB Output is correct
17 Correct 38 ms 82340 KB Output is correct
18 Correct 39 ms 82452 KB Output is correct
19 Correct 38 ms 82300 KB Output is correct
20 Correct 36 ms 82292 KB Output is correct
21 Correct 36 ms 82356 KB Output is correct
22 Correct 47 ms 82380 KB Output is correct
23 Correct 37 ms 82360 KB Output is correct
24 Correct 45 ms 82380 KB Output is correct
25 Correct 36 ms 82380 KB Output is correct
26 Correct 39 ms 82312 KB Output is correct
27 Correct 36 ms 82360 KB Output is correct
28 Correct 39 ms 82380 KB Output is correct
29 Correct 36 ms 82276 KB Output is correct
30 Correct 43 ms 82344 KB Output is correct
31 Correct 39 ms 82384 KB Output is correct
32 Correct 46 ms 82336 KB Output is correct
33 Correct 36 ms 82296 KB Output is correct
34 Correct 36 ms 82388 KB Output is correct
35 Correct 39 ms 82312 KB Output is correct
36 Correct 35 ms 82392 KB Output is correct
37 Correct 41 ms 82344 KB Output is correct
38 Correct 36 ms 82260 KB Output is correct
39 Correct 36 ms 82388 KB Output is correct
40 Correct 35 ms 82364 KB Output is correct
41 Correct 36 ms 82300 KB Output is correct
42 Correct 38 ms 82380 KB Output is correct
43 Correct 37 ms 82380 KB Output is correct
44 Correct 36 ms 82348 KB Output is correct
45 Correct 38 ms 82376 KB Output is correct
46 Correct 37 ms 82336 KB Output is correct
47 Correct 37 ms 82264 KB Output is correct
48 Correct 42 ms 82368 KB Output is correct
49 Correct 35 ms 82384 KB Output is correct
50 Correct 36 ms 82380 KB Output is correct
51 Correct 36 ms 82388 KB Output is correct
52 Correct 36 ms 82272 KB Output is correct
53 Correct 36 ms 82336 KB Output is correct
54 Correct 37 ms 82324 KB Output is correct
55 Correct 37 ms 82380 KB Output is correct
56 Correct 36 ms 82388 KB Output is correct
57 Correct 37 ms 82388 KB Output is correct
58 Correct 47 ms 82320 KB Output is correct
59 Correct 40 ms 82344 KB Output is correct
60 Correct 37 ms 82524 KB Output is correct
61 Correct 40 ms 82416 KB Output is correct
62 Runtime error 94 ms 166832 KB Execution killed with signal 11
63 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 82400 KB Output is correct
2 Correct 37 ms 82364 KB Output is correct
3 Correct 35 ms 82380 KB Output is correct
4 Correct 38 ms 82376 KB Output is correct
5 Correct 36 ms 82388 KB Output is correct
6 Correct 36 ms 82320 KB Output is correct
7 Correct 35 ms 82372 KB Output is correct
8 Correct 36 ms 82264 KB Output is correct
9 Correct 36 ms 82268 KB Output is correct
10 Correct 38 ms 82316 KB Output is correct
11 Correct 36 ms 82252 KB Output is correct
12 Correct 36 ms 82316 KB Output is correct
13 Correct 44 ms 82368 KB Output is correct
14 Correct 39 ms 82272 KB Output is correct
15 Correct 44 ms 82380 KB Output is correct
16 Correct 36 ms 82380 KB Output is correct
17 Correct 38 ms 82340 KB Output is correct
18 Correct 39 ms 82452 KB Output is correct
19 Correct 38 ms 82300 KB Output is correct
20 Correct 36 ms 82292 KB Output is correct
21 Correct 36 ms 82356 KB Output is correct
22 Correct 47 ms 82380 KB Output is correct
23 Correct 37 ms 82360 KB Output is correct
24 Correct 45 ms 82380 KB Output is correct
25 Correct 36 ms 82380 KB Output is correct
26 Correct 39 ms 82312 KB Output is correct
27 Correct 36 ms 82360 KB Output is correct
28 Correct 39 ms 82380 KB Output is correct
29 Correct 36 ms 82276 KB Output is correct
30 Correct 43 ms 82344 KB Output is correct
31 Correct 39 ms 82384 KB Output is correct
32 Correct 46 ms 82336 KB Output is correct
33 Correct 36 ms 82296 KB Output is correct
34 Correct 36 ms 82388 KB Output is correct
35 Correct 39 ms 82312 KB Output is correct
36 Correct 35 ms 82392 KB Output is correct
37 Correct 41 ms 82344 KB Output is correct
38 Correct 36 ms 82260 KB Output is correct
39 Correct 36 ms 82388 KB Output is correct
40 Correct 35 ms 82364 KB Output is correct
41 Correct 36 ms 82300 KB Output is correct
42 Correct 38 ms 82380 KB Output is correct
43 Correct 37 ms 82380 KB Output is correct
44 Correct 36 ms 82348 KB Output is correct
45 Correct 38 ms 82376 KB Output is correct
46 Correct 37 ms 82336 KB Output is correct
47 Correct 37 ms 82264 KB Output is correct
48 Correct 42 ms 82368 KB Output is correct
49 Correct 35 ms 82384 KB Output is correct
50 Correct 36 ms 82380 KB Output is correct
51 Correct 36 ms 82388 KB Output is correct
52 Correct 36 ms 82272 KB Output is correct
53 Correct 36 ms 82336 KB Output is correct
54 Correct 37 ms 82324 KB Output is correct
55 Correct 37 ms 82380 KB Output is correct
56 Correct 36 ms 82388 KB Output is correct
57 Runtime error 114 ms 181000 KB Execution killed with signal 11
58 Halted 0 ms 0 KB -