답안 #867178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867178 2023-10-27T20:05:15 Z PagodePaiva Homework (CEOI22_homework) C++17
100 / 100
438 ms 124568 KB
#include<bits/stdc++.h>

using namespace std;

string s;
map <int, int> virgulas;

int solve(int l, int r){
    if(l == r){
        return 1;
    }

    int con = 0;
    int mid = virgulas[l];

    int a = solve(l+4, mid-1);
    int b = solve(mid+1, r-1);
    if(s[l+1] == 'i'){
        return min(a, b);
    }

    return a+b;
}

int solve2(int l, int r){
    // cout << l << ' ' << r << '\n';

    if(l == r){
        return 1;
    }

    int con = 0;
    int mid = virgulas[l];

    int a = solve2(l+4, mid-1);
    int b = solve2(mid+1, r-1);

    if(s[l+1] == 'a'){
        return min(a, b);
    }

    return a+b;
}

int main(){
    cin >> s;

    int con = 0;
    stack <int> q;

    for(int i = 0;i < s.size();i++){
        if(s[i] ==  '?') con++;
        if(s[i] == 'm') q.push(i);
        if(s[i] == ')') q.pop();
        if(s[i] == ',') virgulas[q.top()] = i;
    }
    int a = solve(0, s.size()-1);    
    int b = solve2(0, s.size()-1);
    b = con-b+1;

    cout << b-a+1 << '\n';
}

Compilation message

Main.cpp: In function 'int solve(int, int)':
Main.cpp:13:9: warning: unused variable 'con' [-Wunused-variable]
   13 |     int con = 0;
      |         ^~~
Main.cpp: In function 'int solve2(int, int)':
Main.cpp:32:9: warning: unused variable 'con' [-Wunused-variable]
   32 |     int con = 0;
      |         ^~~
Main.cpp: In function 'int main()':
Main.cpp:51:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int i = 0;i < s.size();i++){
      |                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 372 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 1 ms 344 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 0 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 412 ms 117176 KB Output is correct
2 Correct 414 ms 124568 KB Output is correct
3 Correct 418 ms 123568 KB Output is correct
4 Correct 428 ms 123572 KB Output is correct
5 Correct 421 ms 123772 KB Output is correct
6 Correct 420 ms 123744 KB Output is correct
7 Correct 412 ms 123772 KB Output is correct
8 Correct 412 ms 123572 KB Output is correct
9 Correct 426 ms 123796 KB Output is correct
10 Correct 418 ms 123680 KB Output is correct
11 Correct 420 ms 124088 KB Output is correct
12 Correct 416 ms 123664 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 372 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 1 ms 344 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 0 ms 548 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 1 ms 348 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 348 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 1 ms 344 KB Output is correct
68 Correct 1 ms 344 KB Output is correct
69 Correct 1 ms 348 KB Output is correct
70 Correct 1 ms 600 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 1 ms 348 KB Output is correct
73 Correct 1 ms 428 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 1 ms 348 KB Output is correct
76 Correct 1 ms 348 KB Output is correct
77 Correct 1 ms 348 KB Output is correct
78 Correct 1 ms 348 KB Output is correct
79 Correct 1 ms 344 KB Output is correct
80 Correct 1 ms 348 KB Output is correct
81 Correct 1 ms 348 KB Output is correct
82 Correct 1 ms 348 KB Output is correct
83 Correct 1 ms 348 KB Output is correct
84 Correct 0 ms 348 KB Output is correct
85 Correct 0 ms 348 KB Output is correct
86 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 372 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 1 ms 344 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 0 ms 548 KB Output is correct
57 Correct 412 ms 117176 KB Output is correct
58 Correct 414 ms 124568 KB Output is correct
59 Correct 418 ms 123568 KB Output is correct
60 Correct 428 ms 123572 KB Output is correct
61 Correct 421 ms 123772 KB Output is correct
62 Correct 420 ms 123744 KB Output is correct
63 Correct 412 ms 123772 KB Output is correct
64 Correct 412 ms 123572 KB Output is correct
65 Correct 426 ms 123796 KB Output is correct
66 Correct 418 ms 123680 KB Output is correct
67 Correct 420 ms 124088 KB Output is correct
68 Correct 416 ms 123664 KB Output is correct
69 Correct 1 ms 344 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 1 ms 348 KB Output is correct
73 Correct 0 ms 348 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 1 ms 348 KB Output is correct
76 Correct 1 ms 348 KB Output is correct
77 Correct 1 ms 348 KB Output is correct
78 Correct 1 ms 348 KB Output is correct
79 Correct 1 ms 348 KB Output is correct
80 Correct 1 ms 344 KB Output is correct
81 Correct 1 ms 344 KB Output is correct
82 Correct 1 ms 348 KB Output is correct
83 Correct 1 ms 600 KB Output is correct
84 Correct 1 ms 348 KB Output is correct
85 Correct 1 ms 348 KB Output is correct
86 Correct 1 ms 428 KB Output is correct
87 Correct 1 ms 348 KB Output is correct
88 Correct 1 ms 348 KB Output is correct
89 Correct 1 ms 348 KB Output is correct
90 Correct 1 ms 348 KB Output is correct
91 Correct 1 ms 348 KB Output is correct
92 Correct 1 ms 344 KB Output is correct
93 Correct 1 ms 348 KB Output is correct
94 Correct 1 ms 348 KB Output is correct
95 Correct 1 ms 348 KB Output is correct
96 Correct 1 ms 348 KB Output is correct
97 Correct 0 ms 348 KB Output is correct
98 Correct 0 ms 348 KB Output is correct
99 Correct 0 ms 348 KB Output is correct
100 Correct 377 ms 61388 KB Output is correct
101 Correct 361 ms 61048 KB Output is correct
102 Correct 374 ms 61216 KB Output is correct
103 Correct 350 ms 61212 KB Output is correct
104 Correct 353 ms 61448 KB Output is correct
105 Correct 398 ms 82700 KB Output is correct
106 Correct 401 ms 81928 KB Output is correct
107 Correct 383 ms 81764 KB Output is correct
108 Correct 394 ms 82024 KB Output is correct
109 Correct 389 ms 82096 KB Output is correct
110 Correct 370 ms 61496 KB Output is correct
111 Correct 368 ms 61616 KB Output is correct
112 Correct 388 ms 61144 KB Output is correct
113 Correct 369 ms 61664 KB Output is correct
114 Correct 370 ms 60860 KB Output is correct
115 Correct 432 ms 124336 KB Output is correct
116 Correct 426 ms 123764 KB Output is correct
117 Correct 414 ms 124412 KB Output is correct
118 Correct 438 ms 123756 KB Output is correct
119 Correct 428 ms 123748 KB Output is correct
120 Correct 360 ms 60852 KB Output is correct
121 Correct 361 ms 61020 KB Output is correct
122 Correct 366 ms 60976 KB Output is correct
123 Correct 388 ms 61068 KB Output is correct
124 Correct 383 ms 94388 KB Output is correct
125 Correct 379 ms 94580 KB Output is correct
126 Correct 374 ms 94784 KB Output is correct
127 Correct 388 ms 94440 KB Output is correct
128 Correct 241 ms 32188 KB Output is correct
129 Correct 247 ms 32088 KB Output is correct
130 Correct 249 ms 32016 KB Output is correct
131 Correct 0 ms 344 KB Output is correct