답안 #772778

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
772778 2023-07-04T11:13:04 Z Valters07 Homework (CEOI22_homework) C++14
100 / 100
153 ms 131416 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define en cin.close();return 0;
#define pb push_back
#define fi first//printf("%lli\n",cur);
#define se second//scanf("%lli",&n);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e6+5;
vector<int> mid[N];
string str;
pair<int,int> go2(int l, int r, int op)
{
    if(l==r)
        return {0,0};
    int pos = mid[op].back();
    mid[op].pop_back();
    auto l1 = go2(l+4,pos-1,op+1), r1 = go2(pos+1,r-1,op+1);
    if(str[l+1]=='i')
        return {min(l1.fi,r1.fi),l1.se+r1.se+1};
    else
        return {l1.fi+r1.fi+1,min(l1.se,r1.se)};
}
int main()
{
    fio
//    ifstream cin("in.in");
    cin >> str;
    int n = 0, op = 0;
    for(int i = str.size()-1;i>=0;i--)
    {
        n+=(str[i]=='?');
        op+=(str[i]==')')-(str[i]=='(');
        if(str[i]==',')
            mid[op].pb(i);
    }
    auto t = go2(0,str.size()-1,1);
    cout << n-t.fi-t.se << endl;
//    cin.close();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23808 KB Output is correct
2 Correct 12 ms 23808 KB Output is correct
3 Correct 10 ms 23808 KB Output is correct
4 Correct 11 ms 23692 KB Output is correct
5 Correct 11 ms 23808 KB Output is correct
6 Correct 10 ms 23816 KB Output is correct
7 Correct 11 ms 23716 KB Output is correct
8 Correct 13 ms 23812 KB Output is correct
9 Correct 11 ms 23732 KB Output is correct
10 Correct 11 ms 23708 KB Output is correct
11 Correct 10 ms 23684 KB Output is correct
12 Correct 10 ms 23816 KB Output is correct
13 Correct 11 ms 23816 KB Output is correct
14 Correct 12 ms 23764 KB Output is correct
15 Correct 13 ms 23812 KB Output is correct
16 Correct 14 ms 23812 KB Output is correct
17 Correct 15 ms 23756 KB Output is correct
18 Correct 16 ms 23776 KB Output is correct
19 Correct 12 ms 23928 KB Output is correct
20 Correct 14 ms 23812 KB Output is correct
21 Correct 15 ms 23720 KB Output is correct
22 Correct 11 ms 23760 KB Output is correct
23 Correct 11 ms 23672 KB Output is correct
24 Correct 13 ms 23716 KB Output is correct
25 Correct 12 ms 23764 KB Output is correct
26 Correct 16 ms 23808 KB Output is correct
27 Correct 13 ms 23764 KB Output is correct
28 Correct 16 ms 23812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23808 KB Output is correct
2 Correct 12 ms 23808 KB Output is correct
3 Correct 10 ms 23808 KB Output is correct
4 Correct 11 ms 23692 KB Output is correct
5 Correct 11 ms 23808 KB Output is correct
6 Correct 10 ms 23816 KB Output is correct
7 Correct 11 ms 23716 KB Output is correct
8 Correct 13 ms 23812 KB Output is correct
9 Correct 11 ms 23732 KB Output is correct
10 Correct 11 ms 23708 KB Output is correct
11 Correct 10 ms 23684 KB Output is correct
12 Correct 10 ms 23816 KB Output is correct
13 Correct 11 ms 23816 KB Output is correct
14 Correct 12 ms 23764 KB Output is correct
15 Correct 13 ms 23812 KB Output is correct
16 Correct 14 ms 23812 KB Output is correct
17 Correct 15 ms 23756 KB Output is correct
18 Correct 16 ms 23776 KB Output is correct
19 Correct 12 ms 23928 KB Output is correct
20 Correct 14 ms 23812 KB Output is correct
21 Correct 15 ms 23720 KB Output is correct
22 Correct 11 ms 23760 KB Output is correct
23 Correct 11 ms 23672 KB Output is correct
24 Correct 13 ms 23716 KB Output is correct
25 Correct 12 ms 23764 KB Output is correct
26 Correct 16 ms 23808 KB Output is correct
27 Correct 13 ms 23764 KB Output is correct
28 Correct 16 ms 23812 KB Output is correct
29 Correct 15 ms 23764 KB Output is correct
30 Correct 11 ms 23712 KB Output is correct
31 Correct 14 ms 23764 KB Output is correct
32 Correct 13 ms 23804 KB Output is correct
33 Correct 13 ms 23764 KB Output is correct
34 Correct 14 ms 23812 KB Output is correct
35 Correct 12 ms 23736 KB Output is correct
36 Correct 12 ms 23716 KB Output is correct
37 Correct 12 ms 23792 KB Output is correct
38 Correct 14 ms 23812 KB Output is correct
39 Correct 11 ms 23764 KB Output is correct
40 Correct 12 ms 23812 KB Output is correct
41 Correct 12 ms 23812 KB Output is correct
42 Correct 11 ms 23696 KB Output is correct
43 Correct 11 ms 23816 KB Output is correct
44 Correct 10 ms 23808 KB Output is correct
45 Correct 12 ms 23812 KB Output is correct
46 Correct 16 ms 23764 KB Output is correct
47 Correct 14 ms 23732 KB Output is correct
48 Correct 14 ms 23764 KB Output is correct
49 Correct 13 ms 23812 KB Output is correct
50 Correct 13 ms 23812 KB Output is correct
51 Correct 13 ms 23804 KB Output is correct
52 Correct 14 ms 23788 KB Output is correct
53 Correct 13 ms 23812 KB Output is correct
54 Correct 14 ms 23692 KB Output is correct
55 Correct 14 ms 23788 KB Output is correct
56 Correct 13 ms 23764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 127300 KB Output is correct
2 Correct 141 ms 125648 KB Output is correct
3 Correct 127 ms 125660 KB Output is correct
4 Correct 133 ms 125656 KB Output is correct
5 Correct 153 ms 125664 KB Output is correct
6 Correct 125 ms 125656 KB Output is correct
7 Correct 121 ms 125624 KB Output is correct
8 Correct 141 ms 125612 KB Output is correct
9 Correct 123 ms 125568 KB Output is correct
10 Correct 122 ms 125600 KB Output is correct
11 Correct 152 ms 125600 KB Output is correct
12 Correct 126 ms 125580 KB Output is correct
13 Correct 12 ms 23776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23808 KB Output is correct
2 Correct 12 ms 23808 KB Output is correct
3 Correct 10 ms 23808 KB Output is correct
4 Correct 11 ms 23692 KB Output is correct
5 Correct 11 ms 23808 KB Output is correct
6 Correct 10 ms 23816 KB Output is correct
7 Correct 11 ms 23716 KB Output is correct
8 Correct 13 ms 23812 KB Output is correct
9 Correct 11 ms 23732 KB Output is correct
10 Correct 11 ms 23708 KB Output is correct
11 Correct 10 ms 23684 KB Output is correct
12 Correct 10 ms 23816 KB Output is correct
13 Correct 11 ms 23816 KB Output is correct
14 Correct 12 ms 23764 KB Output is correct
15 Correct 13 ms 23812 KB Output is correct
16 Correct 14 ms 23812 KB Output is correct
17 Correct 15 ms 23756 KB Output is correct
18 Correct 16 ms 23776 KB Output is correct
19 Correct 12 ms 23928 KB Output is correct
20 Correct 14 ms 23812 KB Output is correct
21 Correct 15 ms 23720 KB Output is correct
22 Correct 11 ms 23760 KB Output is correct
23 Correct 11 ms 23672 KB Output is correct
24 Correct 13 ms 23716 KB Output is correct
25 Correct 12 ms 23764 KB Output is correct
26 Correct 16 ms 23808 KB Output is correct
27 Correct 13 ms 23764 KB Output is correct
28 Correct 16 ms 23812 KB Output is correct
29 Correct 15 ms 23764 KB Output is correct
30 Correct 11 ms 23712 KB Output is correct
31 Correct 14 ms 23764 KB Output is correct
32 Correct 13 ms 23804 KB Output is correct
33 Correct 13 ms 23764 KB Output is correct
34 Correct 14 ms 23812 KB Output is correct
35 Correct 12 ms 23736 KB Output is correct
36 Correct 12 ms 23716 KB Output is correct
37 Correct 12 ms 23792 KB Output is correct
38 Correct 14 ms 23812 KB Output is correct
39 Correct 11 ms 23764 KB Output is correct
40 Correct 12 ms 23812 KB Output is correct
41 Correct 12 ms 23812 KB Output is correct
42 Correct 11 ms 23696 KB Output is correct
43 Correct 11 ms 23816 KB Output is correct
44 Correct 10 ms 23808 KB Output is correct
45 Correct 12 ms 23812 KB Output is correct
46 Correct 16 ms 23764 KB Output is correct
47 Correct 14 ms 23732 KB Output is correct
48 Correct 14 ms 23764 KB Output is correct
49 Correct 13 ms 23812 KB Output is correct
50 Correct 13 ms 23812 KB Output is correct
51 Correct 13 ms 23804 KB Output is correct
52 Correct 14 ms 23788 KB Output is correct
53 Correct 13 ms 23812 KB Output is correct
54 Correct 14 ms 23692 KB Output is correct
55 Correct 14 ms 23788 KB Output is correct
56 Correct 13 ms 23764 KB Output is correct
57 Correct 12 ms 23764 KB Output is correct
58 Correct 13 ms 23808 KB Output is correct
59 Correct 12 ms 23780 KB Output is correct
60 Correct 12 ms 23764 KB Output is correct
61 Correct 14 ms 23712 KB Output is correct
62 Correct 12 ms 23812 KB Output is correct
63 Correct 15 ms 23812 KB Output is correct
64 Correct 11 ms 23764 KB Output is correct
65 Correct 12 ms 23812 KB Output is correct
66 Correct 11 ms 23816 KB Output is correct
67 Correct 16 ms 23800 KB Output is correct
68 Correct 13 ms 23724 KB Output is correct
69 Correct 14 ms 23892 KB Output is correct
70 Correct 12 ms 23764 KB Output is correct
71 Correct 12 ms 23736 KB Output is correct
72 Correct 12 ms 23848 KB Output is correct
73 Correct 13 ms 23812 KB Output is correct
74 Correct 12 ms 23896 KB Output is correct
75 Correct 13 ms 23816 KB Output is correct
76 Correct 13 ms 23892 KB Output is correct
77 Correct 12 ms 23764 KB Output is correct
78 Correct 12 ms 23764 KB Output is correct
79 Correct 12 ms 23736 KB Output is correct
80 Correct 13 ms 23820 KB Output is correct
81 Correct 14 ms 23904 KB Output is correct
82 Correct 12 ms 23764 KB Output is correct
83 Correct 13 ms 23764 KB Output is correct
84 Correct 13 ms 23740 KB Output is correct
85 Correct 12 ms 23752 KB Output is correct
86 Correct 12 ms 23696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23808 KB Output is correct
2 Correct 12 ms 23808 KB Output is correct
3 Correct 10 ms 23808 KB Output is correct
4 Correct 11 ms 23692 KB Output is correct
5 Correct 11 ms 23808 KB Output is correct
6 Correct 10 ms 23816 KB Output is correct
7 Correct 11 ms 23716 KB Output is correct
8 Correct 13 ms 23812 KB Output is correct
9 Correct 11 ms 23732 KB Output is correct
10 Correct 11 ms 23708 KB Output is correct
11 Correct 10 ms 23684 KB Output is correct
12 Correct 10 ms 23816 KB Output is correct
13 Correct 11 ms 23816 KB Output is correct
14 Correct 12 ms 23764 KB Output is correct
15 Correct 13 ms 23812 KB Output is correct
16 Correct 14 ms 23812 KB Output is correct
17 Correct 15 ms 23756 KB Output is correct
18 Correct 16 ms 23776 KB Output is correct
19 Correct 12 ms 23928 KB Output is correct
20 Correct 14 ms 23812 KB Output is correct
21 Correct 15 ms 23720 KB Output is correct
22 Correct 11 ms 23760 KB Output is correct
23 Correct 11 ms 23672 KB Output is correct
24 Correct 13 ms 23716 KB Output is correct
25 Correct 12 ms 23764 KB Output is correct
26 Correct 16 ms 23808 KB Output is correct
27 Correct 13 ms 23764 KB Output is correct
28 Correct 16 ms 23812 KB Output is correct
29 Correct 15 ms 23764 KB Output is correct
30 Correct 11 ms 23712 KB Output is correct
31 Correct 14 ms 23764 KB Output is correct
32 Correct 13 ms 23804 KB Output is correct
33 Correct 13 ms 23764 KB Output is correct
34 Correct 14 ms 23812 KB Output is correct
35 Correct 12 ms 23736 KB Output is correct
36 Correct 12 ms 23716 KB Output is correct
37 Correct 12 ms 23792 KB Output is correct
38 Correct 14 ms 23812 KB Output is correct
39 Correct 11 ms 23764 KB Output is correct
40 Correct 12 ms 23812 KB Output is correct
41 Correct 12 ms 23812 KB Output is correct
42 Correct 11 ms 23696 KB Output is correct
43 Correct 11 ms 23816 KB Output is correct
44 Correct 10 ms 23808 KB Output is correct
45 Correct 12 ms 23812 KB Output is correct
46 Correct 16 ms 23764 KB Output is correct
47 Correct 14 ms 23732 KB Output is correct
48 Correct 14 ms 23764 KB Output is correct
49 Correct 13 ms 23812 KB Output is correct
50 Correct 13 ms 23812 KB Output is correct
51 Correct 13 ms 23804 KB Output is correct
52 Correct 14 ms 23788 KB Output is correct
53 Correct 13 ms 23812 KB Output is correct
54 Correct 14 ms 23692 KB Output is correct
55 Correct 14 ms 23788 KB Output is correct
56 Correct 13 ms 23764 KB Output is correct
57 Correct 132 ms 127300 KB Output is correct
58 Correct 141 ms 125648 KB Output is correct
59 Correct 127 ms 125660 KB Output is correct
60 Correct 133 ms 125656 KB Output is correct
61 Correct 153 ms 125664 KB Output is correct
62 Correct 125 ms 125656 KB Output is correct
63 Correct 121 ms 125624 KB Output is correct
64 Correct 141 ms 125612 KB Output is correct
65 Correct 123 ms 125568 KB Output is correct
66 Correct 122 ms 125600 KB Output is correct
67 Correct 152 ms 125600 KB Output is correct
68 Correct 126 ms 125580 KB Output is correct
69 Correct 12 ms 23776 KB Output is correct
70 Correct 12 ms 23764 KB Output is correct
71 Correct 13 ms 23808 KB Output is correct
72 Correct 12 ms 23780 KB Output is correct
73 Correct 12 ms 23764 KB Output is correct
74 Correct 14 ms 23712 KB Output is correct
75 Correct 12 ms 23812 KB Output is correct
76 Correct 15 ms 23812 KB Output is correct
77 Correct 11 ms 23764 KB Output is correct
78 Correct 12 ms 23812 KB Output is correct
79 Correct 11 ms 23816 KB Output is correct
80 Correct 16 ms 23800 KB Output is correct
81 Correct 13 ms 23724 KB Output is correct
82 Correct 14 ms 23892 KB Output is correct
83 Correct 12 ms 23764 KB Output is correct
84 Correct 12 ms 23736 KB Output is correct
85 Correct 12 ms 23848 KB Output is correct
86 Correct 13 ms 23812 KB Output is correct
87 Correct 12 ms 23896 KB Output is correct
88 Correct 13 ms 23816 KB Output is correct
89 Correct 13 ms 23892 KB Output is correct
90 Correct 12 ms 23764 KB Output is correct
91 Correct 12 ms 23764 KB Output is correct
92 Correct 12 ms 23736 KB Output is correct
93 Correct 13 ms 23820 KB Output is correct
94 Correct 14 ms 23904 KB Output is correct
95 Correct 12 ms 23764 KB Output is correct
96 Correct 13 ms 23764 KB Output is correct
97 Correct 13 ms 23740 KB Output is correct
98 Correct 12 ms 23752 KB Output is correct
99 Correct 12 ms 23696 KB Output is correct
100 Correct 59 ms 43724 KB Output is correct
101 Correct 58 ms 43608 KB Output is correct
102 Correct 52 ms 43604 KB Output is correct
103 Correct 51 ms 43440 KB Output is correct
104 Correct 53 ms 43480 KB Output is correct
105 Correct 91 ms 69144 KB Output is correct
106 Correct 96 ms 69164 KB Output is correct
107 Correct 90 ms 69056 KB Output is correct
108 Correct 92 ms 69108 KB Output is correct
109 Correct 91 ms 69056 KB Output is correct
110 Correct 64 ms 42832 KB Output is correct
111 Correct 57 ms 43108 KB Output is correct
112 Correct 58 ms 43172 KB Output is correct
113 Correct 54 ms 43396 KB Output is correct
114 Correct 55 ms 42968 KB Output is correct
115 Correct 124 ms 131352 KB Output is correct
116 Correct 120 ms 131412 KB Output is correct
117 Correct 127 ms 131408 KB Output is correct
118 Correct 119 ms 131416 KB Output is correct
119 Correct 124 ms 131360 KB Output is correct
120 Correct 56 ms 43092 KB Output is correct
121 Correct 52 ms 43280 KB Output is correct
122 Correct 56 ms 43292 KB Output is correct
123 Correct 58 ms 43076 KB Output is correct
124 Correct 81 ms 86688 KB Output is correct
125 Correct 79 ms 86612 KB Output is correct
126 Correct 78 ms 86688 KB Output is correct
127 Correct 79 ms 86620 KB Output is correct
128 Correct 29 ms 33032 KB Output is correct
129 Correct 28 ms 32980 KB Output is correct
130 Correct 27 ms 33020 KB Output is correct
131 Correct 12 ms 23812 KB Output is correct