답안 #861230

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861230 2023-10-15T16:58:29 Z vgtcross Homework (CEOI22_homework) C++17
53 / 100
165 ms 218052 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = int(1e6) + 1000;

vector<int> ch[N];
vector<int> d[N];
int l[N], r[N];
int x[N];

void solve() {
    string s;
    cin >> s;
    
    vector<pii> st;
    st.push_back({0, 0});
    
    int w = 1;
    int i = 0;
    while (i < s.size()) {
        if (s[i] == '?') {
            ch[st.back().first].push_back(w);
            d[st.back().second+1].push_back(w++);
        } else if (s[i] == 'm') {
            x[w] = s[i+1] == 'a' ? 2 : 1;
            ch[st.back().first].push_back(w);
            d[st.back().second+1].push_back(w);
            st.push_back({w++, st.back().second+1});
            i += 3;
        } else if (s[i] == ')') st.pop_back();
        ++i;
    }
    
    for (int i = 1e6; i > 0; --i) {
        for (int u : d[i]) {
            if (x[u] == 0) {
                l[u] = r[u] = 0;
            } else if (x[u] == 1) {
                l[u] = min(l[ch[u][0]], l[ch[u][1]]);
                r[u] = r[ch[u][0]] + r[ch[u][1]] + 1;
            } else {
                l[u] = l[ch[u][0]] + l[ch[u][1]] + 1;
                r[u] = min(r[ch[u][0]], r[ch[u][1]]);
            }
        }
    }
    
    int cnt = 0;
    for (char c : s) cnt += c == '?';
    cout << cnt - l[1] - r[1] << '\n';
}

int main() {
    cin.tie(0) -> sync_with_stdio(0);
    
    solve();
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:23:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     while (i < s.size()) {
      |            ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 52828 KB Output is correct
2 Correct 12 ms 52848 KB Output is correct
3 Correct 13 ms 52828 KB Output is correct
4 Correct 12 ms 52880 KB Output is correct
5 Correct 13 ms 52828 KB Output is correct
6 Correct 13 ms 52828 KB Output is correct
7 Correct 12 ms 52828 KB Output is correct
8 Correct 13 ms 52824 KB Output is correct
9 Correct 14 ms 52828 KB Output is correct
10 Correct 13 ms 52828 KB Output is correct
11 Correct 12 ms 52888 KB Output is correct
12 Correct 12 ms 52828 KB Output is correct
13 Correct 12 ms 52828 KB Output is correct
14 Correct 12 ms 52828 KB Output is correct
15 Correct 14 ms 52824 KB Output is correct
16 Correct 13 ms 52828 KB Output is correct
17 Correct 13 ms 52828 KB Output is correct
18 Correct 12 ms 52828 KB Output is correct
19 Correct 12 ms 52828 KB Output is correct
20 Correct 12 ms 52828 KB Output is correct
21 Correct 12 ms 52828 KB Output is correct
22 Correct 12 ms 52820 KB Output is correct
23 Correct 12 ms 52828 KB Output is correct
24 Correct 13 ms 52812 KB Output is correct
25 Correct 12 ms 52828 KB Output is correct
26 Correct 13 ms 52884 KB Output is correct
27 Correct 13 ms 52824 KB Output is correct
28 Correct 12 ms 52828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 52828 KB Output is correct
2 Correct 12 ms 52848 KB Output is correct
3 Correct 13 ms 52828 KB Output is correct
4 Correct 12 ms 52880 KB Output is correct
5 Correct 13 ms 52828 KB Output is correct
6 Correct 13 ms 52828 KB Output is correct
7 Correct 12 ms 52828 KB Output is correct
8 Correct 13 ms 52824 KB Output is correct
9 Correct 14 ms 52828 KB Output is correct
10 Correct 13 ms 52828 KB Output is correct
11 Correct 12 ms 52888 KB Output is correct
12 Correct 12 ms 52828 KB Output is correct
13 Correct 12 ms 52828 KB Output is correct
14 Correct 12 ms 52828 KB Output is correct
15 Correct 14 ms 52824 KB Output is correct
16 Correct 13 ms 52828 KB Output is correct
17 Correct 13 ms 52828 KB Output is correct
18 Correct 12 ms 52828 KB Output is correct
19 Correct 12 ms 52828 KB Output is correct
20 Correct 12 ms 52828 KB Output is correct
21 Correct 12 ms 52828 KB Output is correct
22 Correct 12 ms 52820 KB Output is correct
23 Correct 12 ms 52828 KB Output is correct
24 Correct 13 ms 52812 KB Output is correct
25 Correct 12 ms 52828 KB Output is correct
26 Correct 13 ms 52884 KB Output is correct
27 Correct 13 ms 52824 KB Output is correct
28 Correct 12 ms 52828 KB Output is correct
29 Correct 12 ms 52828 KB Output is correct
30 Correct 13 ms 52836 KB Output is correct
31 Correct 12 ms 52828 KB Output is correct
32 Correct 12 ms 52828 KB Output is correct
33 Correct 13 ms 52828 KB Output is correct
34 Correct 12 ms 52828 KB Output is correct
35 Correct 13 ms 52832 KB Output is correct
36 Correct 12 ms 52824 KB Output is correct
37 Correct 12 ms 52828 KB Output is correct
38 Correct 12 ms 52828 KB Output is correct
39 Correct 13 ms 52816 KB Output is correct
40 Correct 12 ms 52828 KB Output is correct
41 Correct 15 ms 53084 KB Output is correct
42 Correct 15 ms 52828 KB Output is correct
43 Correct 12 ms 52824 KB Output is correct
44 Correct 13 ms 52828 KB Output is correct
45 Correct 13 ms 52828 KB Output is correct
46 Correct 13 ms 52828 KB Output is correct
47 Correct 12 ms 52828 KB Output is correct
48 Correct 12 ms 52824 KB Output is correct
49 Correct 13 ms 52700 KB Output is correct
50 Correct 12 ms 52824 KB Output is correct
51 Correct 14 ms 52828 KB Output is correct
52 Correct 14 ms 52828 KB Output is correct
53 Correct 14 ms 52884 KB Output is correct
54 Correct 12 ms 52828 KB Output is correct
55 Correct 13 ms 52828 KB Output is correct
56 Correct 12 ms 52828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 165 ms 218052 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 52828 KB Output is correct
2 Correct 12 ms 52848 KB Output is correct
3 Correct 13 ms 52828 KB Output is correct
4 Correct 12 ms 52880 KB Output is correct
5 Correct 13 ms 52828 KB Output is correct
6 Correct 13 ms 52828 KB Output is correct
7 Correct 12 ms 52828 KB Output is correct
8 Correct 13 ms 52824 KB Output is correct
9 Correct 14 ms 52828 KB Output is correct
10 Correct 13 ms 52828 KB Output is correct
11 Correct 12 ms 52888 KB Output is correct
12 Correct 12 ms 52828 KB Output is correct
13 Correct 12 ms 52828 KB Output is correct
14 Correct 12 ms 52828 KB Output is correct
15 Correct 14 ms 52824 KB Output is correct
16 Correct 13 ms 52828 KB Output is correct
17 Correct 13 ms 52828 KB Output is correct
18 Correct 12 ms 52828 KB Output is correct
19 Correct 12 ms 52828 KB Output is correct
20 Correct 12 ms 52828 KB Output is correct
21 Correct 12 ms 52828 KB Output is correct
22 Correct 12 ms 52820 KB Output is correct
23 Correct 12 ms 52828 KB Output is correct
24 Correct 13 ms 52812 KB Output is correct
25 Correct 12 ms 52828 KB Output is correct
26 Correct 13 ms 52884 KB Output is correct
27 Correct 13 ms 52824 KB Output is correct
28 Correct 12 ms 52828 KB Output is correct
29 Correct 12 ms 52828 KB Output is correct
30 Correct 13 ms 52836 KB Output is correct
31 Correct 12 ms 52828 KB Output is correct
32 Correct 12 ms 52828 KB Output is correct
33 Correct 13 ms 52828 KB Output is correct
34 Correct 12 ms 52828 KB Output is correct
35 Correct 13 ms 52832 KB Output is correct
36 Correct 12 ms 52824 KB Output is correct
37 Correct 12 ms 52828 KB Output is correct
38 Correct 12 ms 52828 KB Output is correct
39 Correct 13 ms 52816 KB Output is correct
40 Correct 12 ms 52828 KB Output is correct
41 Correct 15 ms 53084 KB Output is correct
42 Correct 15 ms 52828 KB Output is correct
43 Correct 12 ms 52824 KB Output is correct
44 Correct 13 ms 52828 KB Output is correct
45 Correct 13 ms 52828 KB Output is correct
46 Correct 13 ms 52828 KB Output is correct
47 Correct 12 ms 52828 KB Output is correct
48 Correct 12 ms 52824 KB Output is correct
49 Correct 13 ms 52700 KB Output is correct
50 Correct 12 ms 52824 KB Output is correct
51 Correct 14 ms 52828 KB Output is correct
52 Correct 14 ms 52828 KB Output is correct
53 Correct 14 ms 52884 KB Output is correct
54 Correct 12 ms 52828 KB Output is correct
55 Correct 13 ms 52828 KB Output is correct
56 Correct 12 ms 52828 KB Output is correct
57 Correct 12 ms 52828 KB Output is correct
58 Correct 15 ms 52824 KB Output is correct
59 Correct 12 ms 52828 KB Output is correct
60 Correct 13 ms 52828 KB Output is correct
61 Correct 12 ms 52828 KB Output is correct
62 Correct 13 ms 52952 KB Output is correct
63 Correct 12 ms 52828 KB Output is correct
64 Correct 12 ms 52828 KB Output is correct
65 Correct 12 ms 52952 KB Output is correct
66 Correct 12 ms 52828 KB Output is correct
67 Correct 13 ms 52808 KB Output is correct
68 Correct 13 ms 52828 KB Output is correct
69 Correct 12 ms 52928 KB Output is correct
70 Correct 12 ms 52824 KB Output is correct
71 Correct 12 ms 52824 KB Output is correct
72 Correct 12 ms 52988 KB Output is correct
73 Correct 13 ms 52980 KB Output is correct
74 Correct 12 ms 52828 KB Output is correct
75 Correct 12 ms 52984 KB Output is correct
76 Correct 13 ms 52828 KB Output is correct
77 Correct 13 ms 52956 KB Output is correct
78 Correct 13 ms 52828 KB Output is correct
79 Correct 14 ms 52828 KB Output is correct
80 Correct 12 ms 52824 KB Output is correct
81 Correct 12 ms 52828 KB Output is correct
82 Correct 12 ms 52824 KB Output is correct
83 Correct 14 ms 52840 KB Output is correct
84 Correct 12 ms 52916 KB Output is correct
85 Correct 12 ms 52824 KB Output is correct
86 Correct 13 ms 52880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 52828 KB Output is correct
2 Correct 12 ms 52848 KB Output is correct
3 Correct 13 ms 52828 KB Output is correct
4 Correct 12 ms 52880 KB Output is correct
5 Correct 13 ms 52828 KB Output is correct
6 Correct 13 ms 52828 KB Output is correct
7 Correct 12 ms 52828 KB Output is correct
8 Correct 13 ms 52824 KB Output is correct
9 Correct 14 ms 52828 KB Output is correct
10 Correct 13 ms 52828 KB Output is correct
11 Correct 12 ms 52888 KB Output is correct
12 Correct 12 ms 52828 KB Output is correct
13 Correct 12 ms 52828 KB Output is correct
14 Correct 12 ms 52828 KB Output is correct
15 Correct 14 ms 52824 KB Output is correct
16 Correct 13 ms 52828 KB Output is correct
17 Correct 13 ms 52828 KB Output is correct
18 Correct 12 ms 52828 KB Output is correct
19 Correct 12 ms 52828 KB Output is correct
20 Correct 12 ms 52828 KB Output is correct
21 Correct 12 ms 52828 KB Output is correct
22 Correct 12 ms 52820 KB Output is correct
23 Correct 12 ms 52828 KB Output is correct
24 Correct 13 ms 52812 KB Output is correct
25 Correct 12 ms 52828 KB Output is correct
26 Correct 13 ms 52884 KB Output is correct
27 Correct 13 ms 52824 KB Output is correct
28 Correct 12 ms 52828 KB Output is correct
29 Correct 12 ms 52828 KB Output is correct
30 Correct 13 ms 52836 KB Output is correct
31 Correct 12 ms 52828 KB Output is correct
32 Correct 12 ms 52828 KB Output is correct
33 Correct 13 ms 52828 KB Output is correct
34 Correct 12 ms 52828 KB Output is correct
35 Correct 13 ms 52832 KB Output is correct
36 Correct 12 ms 52824 KB Output is correct
37 Correct 12 ms 52828 KB Output is correct
38 Correct 12 ms 52828 KB Output is correct
39 Correct 13 ms 52816 KB Output is correct
40 Correct 12 ms 52828 KB Output is correct
41 Correct 15 ms 53084 KB Output is correct
42 Correct 15 ms 52828 KB Output is correct
43 Correct 12 ms 52824 KB Output is correct
44 Correct 13 ms 52828 KB Output is correct
45 Correct 13 ms 52828 KB Output is correct
46 Correct 13 ms 52828 KB Output is correct
47 Correct 12 ms 52828 KB Output is correct
48 Correct 12 ms 52824 KB Output is correct
49 Correct 13 ms 52700 KB Output is correct
50 Correct 12 ms 52824 KB Output is correct
51 Correct 14 ms 52828 KB Output is correct
52 Correct 14 ms 52828 KB Output is correct
53 Correct 14 ms 52884 KB Output is correct
54 Correct 12 ms 52828 KB Output is correct
55 Correct 13 ms 52828 KB Output is correct
56 Correct 12 ms 52828 KB Output is correct
57 Runtime error 165 ms 218052 KB Execution killed with signal 11
58 Halted 0 ms 0 KB -