Submission #1066981

# Submission time Handle Problem Language Result Execution time Memory
1066981 2024-08-20T09:14:45 Z Andrey Homework (CEOI22_homework) C++14
100 / 100
212 ms 190672 KB
#include<bits/stdc++.h>
using namespace std;

vector<int> haha[3000001];
vector<bool> bruh(3000001);
vector<pair<int,int>> dp(3000001);

void dfs(int a) {
    if(haha[a].empty()) {
        dp[a] = {0,0};
        return;
    }
    dfs(haha[a][0]);
    dfs(haha[a][1]);
    pair<int,int> c = dp[haha[a][0]];
    pair<int,int> d = dp[haha[a][1]];
    if(bruh[a]) {
        dp[a] = {min(c.first,d.first),c.second+d.second+1};
    }
    else {
        dp[a] = {c.first+d.first+1,min(c.second,d.second)};
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    int y = 0,br = 1,n = 0;
    vector<int> wut(1);
    while(y < s.size()) {
        if(s[y] == 'm') {
            haha[wut[wut.size()-1]].push_back(br);
            wut.push_back(br);
            if(s[y+1] == 'i') {
                bruh[br] = 1;
            }
            else {
                bruh[br] = 0;
            }
            br++;
            y+=4;
        }
        else if(s[y] == '?') {
            haha[wut[wut.size()-1]].push_back(br);
            n++;
            br++;
            y++;
        }
        else if(s[y] == ')') {
            wut.pop_back();
            y++;
        }
        else {
            y++;
        }
    }
    dfs(1);
    cout << n-dp[1].first-dp[1].second;
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:34:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     while(y < s.size()) {
      |           ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 40 ms 94556 KB Output is correct
2 Correct 38 ms 94580 KB Output is correct
3 Correct 38 ms 94552 KB Output is correct
4 Correct 43 ms 94544 KB Output is correct
5 Correct 39 ms 94536 KB Output is correct
6 Correct 38 ms 94556 KB Output is correct
7 Correct 44 ms 94720 KB Output is correct
8 Correct 42 ms 94556 KB Output is correct
9 Correct 41 ms 94720 KB Output is correct
10 Correct 37 ms 94548 KB Output is correct
11 Correct 37 ms 94552 KB Output is correct
12 Correct 37 ms 94500 KB Output is correct
13 Correct 37 ms 94532 KB Output is correct
14 Correct 40 ms 94552 KB Output is correct
15 Correct 39 ms 94600 KB Output is correct
16 Correct 42 ms 94556 KB Output is correct
17 Correct 40 ms 94556 KB Output is correct
18 Correct 38 ms 94556 KB Output is correct
19 Correct 37 ms 94556 KB Output is correct
20 Correct 37 ms 94580 KB Output is correct
21 Correct 35 ms 94544 KB Output is correct
22 Correct 42 ms 94544 KB Output is correct
23 Correct 39 ms 94744 KB Output is correct
24 Correct 36 ms 94556 KB Output is correct
25 Correct 35 ms 94544 KB Output is correct
26 Correct 52 ms 94544 KB Output is correct
27 Correct 35 ms 94552 KB Output is correct
28 Correct 34 ms 94548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 94556 KB Output is correct
2 Correct 38 ms 94580 KB Output is correct
3 Correct 38 ms 94552 KB Output is correct
4 Correct 43 ms 94544 KB Output is correct
5 Correct 39 ms 94536 KB Output is correct
6 Correct 38 ms 94556 KB Output is correct
7 Correct 44 ms 94720 KB Output is correct
8 Correct 42 ms 94556 KB Output is correct
9 Correct 41 ms 94720 KB Output is correct
10 Correct 37 ms 94548 KB Output is correct
11 Correct 37 ms 94552 KB Output is correct
12 Correct 37 ms 94500 KB Output is correct
13 Correct 37 ms 94532 KB Output is correct
14 Correct 40 ms 94552 KB Output is correct
15 Correct 39 ms 94600 KB Output is correct
16 Correct 42 ms 94556 KB Output is correct
17 Correct 40 ms 94556 KB Output is correct
18 Correct 38 ms 94556 KB Output is correct
19 Correct 37 ms 94556 KB Output is correct
20 Correct 37 ms 94580 KB Output is correct
21 Correct 35 ms 94544 KB Output is correct
22 Correct 42 ms 94544 KB Output is correct
23 Correct 39 ms 94744 KB Output is correct
24 Correct 36 ms 94556 KB Output is correct
25 Correct 35 ms 94544 KB Output is correct
26 Correct 52 ms 94544 KB Output is correct
27 Correct 35 ms 94552 KB Output is correct
28 Correct 34 ms 94548 KB Output is correct
29 Correct 53 ms 94600 KB Output is correct
30 Correct 35 ms 94556 KB Output is correct
31 Correct 55 ms 94544 KB Output is correct
32 Correct 40 ms 94552 KB Output is correct
33 Correct 37 ms 94752 KB Output is correct
34 Correct 42 ms 94568 KB Output is correct
35 Correct 45 ms 94548 KB Output is correct
36 Correct 38 ms 94592 KB Output is correct
37 Correct 39 ms 94640 KB Output is correct
38 Correct 42 ms 94596 KB Output is correct
39 Correct 37 ms 94588 KB Output is correct
40 Correct 42 ms 94604 KB Output is correct
41 Correct 36 ms 94600 KB Output is correct
42 Correct 38 ms 94684 KB Output is correct
43 Correct 37 ms 94592 KB Output is correct
44 Correct 41 ms 94736 KB Output is correct
45 Correct 39 ms 94588 KB Output is correct
46 Correct 38 ms 94544 KB Output is correct
47 Correct 49 ms 94556 KB Output is correct
48 Correct 44 ms 94548 KB Output is correct
49 Correct 39 ms 94548 KB Output is correct
50 Correct 38 ms 94556 KB Output is correct
51 Correct 40 ms 94688 KB Output is correct
52 Correct 45 ms 94536 KB Output is correct
53 Correct 39 ms 94708 KB Output is correct
54 Correct 40 ms 94540 KB Output is correct
55 Correct 39 ms 94572 KB Output is correct
56 Correct 38 ms 94536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 174 ms 190616 KB Output is correct
2 Correct 191 ms 190624 KB Output is correct
3 Correct 185 ms 190420 KB Output is correct
4 Correct 178 ms 190412 KB Output is correct
5 Correct 171 ms 190672 KB Output is correct
6 Correct 184 ms 190600 KB Output is correct
7 Correct 167 ms 190416 KB Output is correct
8 Correct 173 ms 190592 KB Output is correct
9 Correct 163 ms 190612 KB Output is correct
10 Correct 170 ms 190412 KB Output is correct
11 Correct 171 ms 190596 KB Output is correct
12 Correct 167 ms 190408 KB Output is correct
13 Correct 45 ms 94556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 94556 KB Output is correct
2 Correct 38 ms 94580 KB Output is correct
3 Correct 38 ms 94552 KB Output is correct
4 Correct 43 ms 94544 KB Output is correct
5 Correct 39 ms 94536 KB Output is correct
6 Correct 38 ms 94556 KB Output is correct
7 Correct 44 ms 94720 KB Output is correct
8 Correct 42 ms 94556 KB Output is correct
9 Correct 41 ms 94720 KB Output is correct
10 Correct 37 ms 94548 KB Output is correct
11 Correct 37 ms 94552 KB Output is correct
12 Correct 37 ms 94500 KB Output is correct
13 Correct 37 ms 94532 KB Output is correct
14 Correct 40 ms 94552 KB Output is correct
15 Correct 39 ms 94600 KB Output is correct
16 Correct 42 ms 94556 KB Output is correct
17 Correct 40 ms 94556 KB Output is correct
18 Correct 38 ms 94556 KB Output is correct
19 Correct 37 ms 94556 KB Output is correct
20 Correct 37 ms 94580 KB Output is correct
21 Correct 35 ms 94544 KB Output is correct
22 Correct 42 ms 94544 KB Output is correct
23 Correct 39 ms 94744 KB Output is correct
24 Correct 36 ms 94556 KB Output is correct
25 Correct 35 ms 94544 KB Output is correct
26 Correct 52 ms 94544 KB Output is correct
27 Correct 35 ms 94552 KB Output is correct
28 Correct 34 ms 94548 KB Output is correct
29 Correct 53 ms 94600 KB Output is correct
30 Correct 35 ms 94556 KB Output is correct
31 Correct 55 ms 94544 KB Output is correct
32 Correct 40 ms 94552 KB Output is correct
33 Correct 37 ms 94752 KB Output is correct
34 Correct 42 ms 94568 KB Output is correct
35 Correct 45 ms 94548 KB Output is correct
36 Correct 38 ms 94592 KB Output is correct
37 Correct 39 ms 94640 KB Output is correct
38 Correct 42 ms 94596 KB Output is correct
39 Correct 37 ms 94588 KB Output is correct
40 Correct 42 ms 94604 KB Output is correct
41 Correct 36 ms 94600 KB Output is correct
42 Correct 38 ms 94684 KB Output is correct
43 Correct 37 ms 94592 KB Output is correct
44 Correct 41 ms 94736 KB Output is correct
45 Correct 39 ms 94588 KB Output is correct
46 Correct 38 ms 94544 KB Output is correct
47 Correct 49 ms 94556 KB Output is correct
48 Correct 44 ms 94548 KB Output is correct
49 Correct 39 ms 94548 KB Output is correct
50 Correct 38 ms 94556 KB Output is correct
51 Correct 40 ms 94688 KB Output is correct
52 Correct 45 ms 94536 KB Output is correct
53 Correct 39 ms 94708 KB Output is correct
54 Correct 40 ms 94540 KB Output is correct
55 Correct 39 ms 94572 KB Output is correct
56 Correct 38 ms 94536 KB Output is correct
57 Correct 45 ms 94548 KB Output is correct
58 Correct 38 ms 94544 KB Output is correct
59 Correct 38 ms 94768 KB Output is correct
60 Correct 38 ms 94544 KB Output is correct
61 Correct 38 ms 94544 KB Output is correct
62 Correct 38 ms 94800 KB Output is correct
63 Correct 38 ms 94808 KB Output is correct
64 Correct 40 ms 94808 KB Output is correct
65 Correct 37 ms 94760 KB Output is correct
66 Correct 40 ms 94800 KB Output is correct
67 Correct 40 ms 94540 KB Output is correct
68 Correct 47 ms 94548 KB Output is correct
69 Correct 37 ms 94732 KB Output is correct
70 Correct 41 ms 94692 KB Output is correct
71 Correct 42 ms 94800 KB Output is correct
72 Correct 40 ms 94804 KB Output is correct
73 Correct 42 ms 94800 KB Output is correct
74 Correct 41 ms 94800 KB Output is correct
75 Correct 38 ms 94800 KB Output is correct
76 Correct 45 ms 94804 KB Output is correct
77 Correct 44 ms 94812 KB Output is correct
78 Correct 44 ms 94544 KB Output is correct
79 Correct 43 ms 94548 KB Output is correct
80 Correct 45 ms 94544 KB Output is correct
81 Correct 38 ms 94800 KB Output is correct
82 Correct 39 ms 94812 KB Output is correct
83 Correct 50 ms 94580 KB Output is correct
84 Correct 40 ms 94548 KB Output is correct
85 Correct 54 ms 94592 KB Output is correct
86 Correct 52 ms 94548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 94556 KB Output is correct
2 Correct 38 ms 94580 KB Output is correct
3 Correct 38 ms 94552 KB Output is correct
4 Correct 43 ms 94544 KB Output is correct
5 Correct 39 ms 94536 KB Output is correct
6 Correct 38 ms 94556 KB Output is correct
7 Correct 44 ms 94720 KB Output is correct
8 Correct 42 ms 94556 KB Output is correct
9 Correct 41 ms 94720 KB Output is correct
10 Correct 37 ms 94548 KB Output is correct
11 Correct 37 ms 94552 KB Output is correct
12 Correct 37 ms 94500 KB Output is correct
13 Correct 37 ms 94532 KB Output is correct
14 Correct 40 ms 94552 KB Output is correct
15 Correct 39 ms 94600 KB Output is correct
16 Correct 42 ms 94556 KB Output is correct
17 Correct 40 ms 94556 KB Output is correct
18 Correct 38 ms 94556 KB Output is correct
19 Correct 37 ms 94556 KB Output is correct
20 Correct 37 ms 94580 KB Output is correct
21 Correct 35 ms 94544 KB Output is correct
22 Correct 42 ms 94544 KB Output is correct
23 Correct 39 ms 94744 KB Output is correct
24 Correct 36 ms 94556 KB Output is correct
25 Correct 35 ms 94544 KB Output is correct
26 Correct 52 ms 94544 KB Output is correct
27 Correct 35 ms 94552 KB Output is correct
28 Correct 34 ms 94548 KB Output is correct
29 Correct 53 ms 94600 KB Output is correct
30 Correct 35 ms 94556 KB Output is correct
31 Correct 55 ms 94544 KB Output is correct
32 Correct 40 ms 94552 KB Output is correct
33 Correct 37 ms 94752 KB Output is correct
34 Correct 42 ms 94568 KB Output is correct
35 Correct 45 ms 94548 KB Output is correct
36 Correct 38 ms 94592 KB Output is correct
37 Correct 39 ms 94640 KB Output is correct
38 Correct 42 ms 94596 KB Output is correct
39 Correct 37 ms 94588 KB Output is correct
40 Correct 42 ms 94604 KB Output is correct
41 Correct 36 ms 94600 KB Output is correct
42 Correct 38 ms 94684 KB Output is correct
43 Correct 37 ms 94592 KB Output is correct
44 Correct 41 ms 94736 KB Output is correct
45 Correct 39 ms 94588 KB Output is correct
46 Correct 38 ms 94544 KB Output is correct
47 Correct 49 ms 94556 KB Output is correct
48 Correct 44 ms 94548 KB Output is correct
49 Correct 39 ms 94548 KB Output is correct
50 Correct 38 ms 94556 KB Output is correct
51 Correct 40 ms 94688 KB Output is correct
52 Correct 45 ms 94536 KB Output is correct
53 Correct 39 ms 94708 KB Output is correct
54 Correct 40 ms 94540 KB Output is correct
55 Correct 39 ms 94572 KB Output is correct
56 Correct 38 ms 94536 KB Output is correct
57 Correct 174 ms 190616 KB Output is correct
58 Correct 191 ms 190624 KB Output is correct
59 Correct 185 ms 190420 KB Output is correct
60 Correct 178 ms 190412 KB Output is correct
61 Correct 171 ms 190672 KB Output is correct
62 Correct 184 ms 190600 KB Output is correct
63 Correct 167 ms 190416 KB Output is correct
64 Correct 173 ms 190592 KB Output is correct
65 Correct 163 ms 190612 KB Output is correct
66 Correct 170 ms 190412 KB Output is correct
67 Correct 171 ms 190596 KB Output is correct
68 Correct 167 ms 190408 KB Output is correct
69 Correct 45 ms 94556 KB Output is correct
70 Correct 45 ms 94548 KB Output is correct
71 Correct 38 ms 94544 KB Output is correct
72 Correct 38 ms 94768 KB Output is correct
73 Correct 38 ms 94544 KB Output is correct
74 Correct 38 ms 94544 KB Output is correct
75 Correct 38 ms 94800 KB Output is correct
76 Correct 38 ms 94808 KB Output is correct
77 Correct 40 ms 94808 KB Output is correct
78 Correct 37 ms 94760 KB Output is correct
79 Correct 40 ms 94800 KB Output is correct
80 Correct 40 ms 94540 KB Output is correct
81 Correct 47 ms 94548 KB Output is correct
82 Correct 37 ms 94732 KB Output is correct
83 Correct 41 ms 94692 KB Output is correct
84 Correct 42 ms 94800 KB Output is correct
85 Correct 40 ms 94804 KB Output is correct
86 Correct 42 ms 94800 KB Output is correct
87 Correct 41 ms 94800 KB Output is correct
88 Correct 38 ms 94800 KB Output is correct
89 Correct 45 ms 94804 KB Output is correct
90 Correct 44 ms 94812 KB Output is correct
91 Correct 44 ms 94544 KB Output is correct
92 Correct 43 ms 94548 KB Output is correct
93 Correct 45 ms 94544 KB Output is correct
94 Correct 38 ms 94800 KB Output is correct
95 Correct 39 ms 94812 KB Output is correct
96 Correct 50 ms 94580 KB Output is correct
97 Correct 40 ms 94548 KB Output is correct
98 Correct 54 ms 94592 KB Output is correct
99 Correct 52 ms 94548 KB Output is correct
100 Correct 151 ms 139536 KB Output is correct
101 Correct 159 ms 139644 KB Output is correct
102 Correct 146 ms 139728 KB Output is correct
103 Correct 144 ms 139724 KB Output is correct
104 Correct 147 ms 139724 KB Output is correct
105 Correct 163 ms 156576 KB Output is correct
106 Correct 171 ms 156544 KB Output is correct
107 Correct 178 ms 156620 KB Output is correct
108 Correct 165 ms 156620 KB Output is correct
109 Correct 161 ms 156572 KB Output is correct
110 Correct 152 ms 139724 KB Output is correct
111 Correct 151 ms 139676 KB Output is correct
112 Correct 140 ms 139644 KB Output is correct
113 Correct 151 ms 139644 KB Output is correct
114 Correct 151 ms 139664 KB Output is correct
115 Correct 180 ms 190412 KB Output is correct
116 Correct 212 ms 190520 KB Output is correct
117 Correct 199 ms 190484 KB Output is correct
118 Correct 170 ms 190624 KB Output is correct
119 Correct 184 ms 190592 KB Output is correct
120 Correct 151 ms 139672 KB Output is correct
121 Correct 153 ms 139728 KB Output is correct
122 Correct 161 ms 139724 KB Output is correct
123 Correct 165 ms 139976 KB Output is correct
124 Correct 144 ms 165128 KB Output is correct
125 Correct 143 ms 165000 KB Output is correct
126 Correct 161 ms 165184 KB Output is correct
127 Correct 144 ms 165068 KB Output is correct
128 Correct 82 ms 118228 KB Output is correct
129 Correct 81 ms 118248 KB Output is correct
130 Correct 87 ms 118232 KB Output is correct
131 Correct 38 ms 94548 KB Output is correct