# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
726571 | 2023-04-19T05:41:05 Z | ReLice | Homework (CEOI22_homework) | C++14 | 215 ms | 70688 KB |
#include <bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define endl "\n" #define fr first #define sc second #define sz size() #define bc back() using namespace std;/* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>*/ void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=2e18+7; const ll mod=1e9+7; const ll N=7e6+7; string s; ll n,md[N],a=0; ll rec(ll l,ll r){ ll c=0,mid; if(s[l+4]=='?'){ mid=l+5; } else{ mid=md[l+4]+1; } if(s[l+1]=='i' && s[l+2]=='n'){ if(s[l+4]=='?'){ if(s[r-1]=='?'){ return 2; } return 1+rec(mid+1,r-1); } else if(s[r-1]=='?'){ return rec(l+4,mid-1)+1; } return rec(l+4,mid-1)+rec(mid+1,r-1); } else{ if(s[l+4]=='?' || s[r-1]=='?'){ return 1; } return min(rec(l+4,mid-1),rec(mid+1,r-1)); } } ll rec2(ll l,ll r){ ll c=0,mid; if(s[l+4]=='?'){ mid=l+5; } else{ mid=md[l+4]+1; } if(s[l+1]=='i' && s[l+2]=='n'){ if(s[l+4]=='?' || s[r-1]=='?'){ return 1; } return min(rec2(l+4,mid-1),rec2(mid+1,r-1)); } else{ if(s[l+4]=='?'){ if(s[r-1]=='?'){ return 2; } return 1+rec2(mid+1,r-1); } else if(s[r-1]=='?'){ return rec2(l+4,mid-1)+1; } return rec2(l+4,mid-1)+rec2(mid+1,r-1); } } void solve(){ ll i,j,q,sum=0,b,c=0,c2=0; ll m,i1=-1,l=-5,r=inf; ll k,mn=inf,d,mx=-inf; cin>>s; n=s.sz; vector <ll> v; for(i=0;i<n;i++){ if(s[i]=='?') sum++; if(s[i]=='(') { v.pb(i-3); } if(s[i]==')') { md[v.bc]=i; v.pop_back(); } } c=rec(0,n-1); c2=rec2(0,n-1); cout<<sum-c-c2+2<<endl; } signed main(){ //start(); //fre(""); ll t=1; //cin>>t; while(t--) solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Correct | 0 ms | 212 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 0 ms | 212 KB | Output is correct |
28 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Correct | 0 ms | 212 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 0 ms | 212 KB | Output is correct |
28 | Correct | 0 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 0 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 212 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Correct | 0 ms | 212 KB | Output is correct |
36 | Correct | 0 ms | 212 KB | Output is correct |
37 | Correct | 0 ms | 212 KB | Output is correct |
38 | Correct | 1 ms | 212 KB | Output is correct |
39 | Correct | 0 ms | 212 KB | Output is correct |
40 | Correct | 0 ms | 212 KB | Output is correct |
41 | Correct | 0 ms | 212 KB | Output is correct |
42 | Correct | 0 ms | 212 KB | Output is correct |
43 | Correct | 0 ms | 212 KB | Output is correct |
44 | Correct | 0 ms | 212 KB | Output is correct |
45 | Correct | 0 ms | 212 KB | Output is correct |
46 | Correct | 0 ms | 212 KB | Output is correct |
47 | Correct | 1 ms | 212 KB | Output is correct |
48 | Correct | 0 ms | 212 KB | Output is correct |
49 | Correct | 0 ms | 212 KB | Output is correct |
50 | Correct | 0 ms | 212 KB | Output is correct |
51 | Correct | 0 ms | 212 KB | Output is correct |
52 | Correct | 0 ms | 212 KB | Output is correct |
53 | Correct | 0 ms | 212 KB | Output is correct |
54 | Correct | 0 ms | 212 KB | Output is correct |
55 | Correct | 0 ms | 212 KB | Output is correct |
56 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 199 ms | 58200 KB | Output is correct |
2 | Correct | 201 ms | 60196 KB | Output is correct |
3 | Correct | 182 ms | 60200 KB | Output is correct |
4 | Correct | 201 ms | 60212 KB | Output is correct |
5 | Correct | 188 ms | 60352 KB | Output is correct |
6 | Correct | 179 ms | 60132 KB | Output is correct |
7 | Correct | 189 ms | 60164 KB | Output is correct |
8 | Correct | 189 ms | 60252 KB | Output is correct |
9 | Correct | 180 ms | 60224 KB | Output is correct |
10 | Correct | 188 ms | 60192 KB | Output is correct |
11 | Correct | 187 ms | 60160 KB | Output is correct |
12 | Correct | 188 ms | 60268 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Correct | 0 ms | 212 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 0 ms | 212 KB | Output is correct |
28 | Correct | 0 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 0 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 212 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Correct | 0 ms | 212 KB | Output is correct |
36 | Correct | 0 ms | 212 KB | Output is correct |
37 | Correct | 0 ms | 212 KB | Output is correct |
38 | Correct | 1 ms | 212 KB | Output is correct |
39 | Correct | 0 ms | 212 KB | Output is correct |
40 | Correct | 0 ms | 212 KB | Output is correct |
41 | Correct | 0 ms | 212 KB | Output is correct |
42 | Correct | 0 ms | 212 KB | Output is correct |
43 | Correct | 0 ms | 212 KB | Output is correct |
44 | Correct | 0 ms | 212 KB | Output is correct |
45 | Correct | 0 ms | 212 KB | Output is correct |
46 | Correct | 0 ms | 212 KB | Output is correct |
47 | Correct | 1 ms | 212 KB | Output is correct |
48 | Correct | 0 ms | 212 KB | Output is correct |
49 | Correct | 0 ms | 212 KB | Output is correct |
50 | Correct | 0 ms | 212 KB | Output is correct |
51 | Correct | 0 ms | 212 KB | Output is correct |
52 | Correct | 0 ms | 212 KB | Output is correct |
53 | Correct | 0 ms | 212 KB | Output is correct |
54 | Correct | 0 ms | 212 KB | Output is correct |
55 | Correct | 0 ms | 212 KB | Output is correct |
56 | Correct | 1 ms | 212 KB | Output is correct |
57 | Correct | 1 ms | 340 KB | Output is correct |
58 | Correct | 0 ms | 340 KB | Output is correct |
59 | Correct | 1 ms | 340 KB | Output is correct |
60 | Correct | 1 ms | 340 KB | Output is correct |
61 | Correct | 1 ms | 340 KB | Output is correct |
62 | Correct | 1 ms | 340 KB | Output is correct |
63 | Correct | 1 ms | 340 KB | Output is correct |
64 | Correct | 1 ms | 340 KB | Output is correct |
65 | Correct | 1 ms | 340 KB | Output is correct |
66 | Correct | 1 ms | 340 KB | Output is correct |
67 | Correct | 1 ms | 340 KB | Output is correct |
68 | Correct | 1 ms | 340 KB | Output is correct |
69 | Correct | 1 ms | 340 KB | Output is correct |
70 | Correct | 0 ms | 340 KB | Output is correct |
71 | Correct | 1 ms | 340 KB | Output is correct |
72 | Correct | 1 ms | 340 KB | Output is correct |
73 | Correct | 1 ms | 340 KB | Output is correct |
74 | Correct | 1 ms | 340 KB | Output is correct |
75 | Correct | 1 ms | 340 KB | Output is correct |
76 | Correct | 1 ms | 340 KB | Output is correct |
77 | Correct | 1 ms | 340 KB | Output is correct |
78 | Correct | 1 ms | 340 KB | Output is correct |
79 | Correct | 1 ms | 340 KB | Output is correct |
80 | Correct | 1 ms | 340 KB | Output is correct |
81 | Correct | 1 ms | 340 KB | Output is correct |
82 | Correct | 1 ms | 340 KB | Output is correct |
83 | Correct | 1 ms | 340 KB | Output is correct |
84 | Correct | 0 ms | 340 KB | Output is correct |
85 | Correct | 1 ms | 340 KB | Output is correct |
86 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Correct | 0 ms | 212 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 0 ms | 212 KB | Output is correct |
28 | Correct | 0 ms | 212 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 0 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 212 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Correct | 0 ms | 212 KB | Output is correct |
36 | Correct | 0 ms | 212 KB | Output is correct |
37 | Correct | 0 ms | 212 KB | Output is correct |
38 | Correct | 1 ms | 212 KB | Output is correct |
39 | Correct | 0 ms | 212 KB | Output is correct |
40 | Correct | 0 ms | 212 KB | Output is correct |
41 | Correct | 0 ms | 212 KB | Output is correct |
42 | Correct | 0 ms | 212 KB | Output is correct |
43 | Correct | 0 ms | 212 KB | Output is correct |
44 | Correct | 0 ms | 212 KB | Output is correct |
45 | Correct | 0 ms | 212 KB | Output is correct |
46 | Correct | 0 ms | 212 KB | Output is correct |
47 | Correct | 1 ms | 212 KB | Output is correct |
48 | Correct | 0 ms | 212 KB | Output is correct |
49 | Correct | 0 ms | 212 KB | Output is correct |
50 | Correct | 0 ms | 212 KB | Output is correct |
51 | Correct | 0 ms | 212 KB | Output is correct |
52 | Correct | 0 ms | 212 KB | Output is correct |
53 | Correct | 0 ms | 212 KB | Output is correct |
54 | Correct | 0 ms | 212 KB | Output is correct |
55 | Correct | 0 ms | 212 KB | Output is correct |
56 | Correct | 1 ms | 212 KB | Output is correct |
57 | Correct | 199 ms | 58200 KB | Output is correct |
58 | Correct | 201 ms | 60196 KB | Output is correct |
59 | Correct | 182 ms | 60200 KB | Output is correct |
60 | Correct | 201 ms | 60212 KB | Output is correct |
61 | Correct | 188 ms | 60352 KB | Output is correct |
62 | Correct | 179 ms | 60132 KB | Output is correct |
63 | Correct | 189 ms | 60164 KB | Output is correct |
64 | Correct | 189 ms | 60252 KB | Output is correct |
65 | Correct | 180 ms | 60224 KB | Output is correct |
66 | Correct | 188 ms | 60192 KB | Output is correct |
67 | Correct | 187 ms | 60160 KB | Output is correct |
68 | Correct | 188 ms | 60268 KB | Output is correct |
69 | Correct | 0 ms | 212 KB | Output is correct |
70 | Correct | 1 ms | 340 KB | Output is correct |
71 | Correct | 0 ms | 340 KB | Output is correct |
72 | Correct | 1 ms | 340 KB | Output is correct |
73 | Correct | 1 ms | 340 KB | Output is correct |
74 | Correct | 1 ms | 340 KB | Output is correct |
75 | Correct | 1 ms | 340 KB | Output is correct |
76 | Correct | 1 ms | 340 KB | Output is correct |
77 | Correct | 1 ms | 340 KB | Output is correct |
78 | Correct | 1 ms | 340 KB | Output is correct |
79 | Correct | 1 ms | 340 KB | Output is correct |
80 | Correct | 1 ms | 340 KB | Output is correct |
81 | Correct | 1 ms | 340 KB | Output is correct |
82 | Correct | 1 ms | 340 KB | Output is correct |
83 | Correct | 0 ms | 340 KB | Output is correct |
84 | Correct | 1 ms | 340 KB | Output is correct |
85 | Correct | 1 ms | 340 KB | Output is correct |
86 | Correct | 1 ms | 340 KB | Output is correct |
87 | Correct | 1 ms | 340 KB | Output is correct |
88 | Correct | 1 ms | 340 KB | Output is correct |
89 | Correct | 1 ms | 340 KB | Output is correct |
90 | Correct | 1 ms | 340 KB | Output is correct |
91 | Correct | 1 ms | 340 KB | Output is correct |
92 | Correct | 1 ms | 340 KB | Output is correct |
93 | Correct | 1 ms | 340 KB | Output is correct |
94 | Correct | 1 ms | 340 KB | Output is correct |
95 | Correct | 1 ms | 340 KB | Output is correct |
96 | Correct | 1 ms | 340 KB | Output is correct |
97 | Correct | 0 ms | 340 KB | Output is correct |
98 | Correct | 1 ms | 340 KB | Output is correct |
99 | Correct | 0 ms | 212 KB | Output is correct |
100 | Correct | 209 ms | 64056 KB | Output is correct |
101 | Correct | 210 ms | 64044 KB | Output is correct |
102 | Correct | 206 ms | 63976 KB | Output is correct |
103 | Correct | 208 ms | 64016 KB | Output is correct |
104 | Correct | 201 ms | 64300 KB | Output is correct |
105 | Correct | 185 ms | 70688 KB | Output is correct |
106 | Correct | 179 ms | 70616 KB | Output is correct |
107 | Correct | 184 ms | 70652 KB | Output is correct |
108 | Correct | 189 ms | 70572 KB | Output is correct |
109 | Correct | 183 ms | 70600 KB | Output is correct |
110 | Correct | 215 ms | 64136 KB | Output is correct |
111 | Correct | 214 ms | 64028 KB | Output is correct |
112 | Correct | 212 ms | 63988 KB | Output is correct |
113 | Correct | 205 ms | 64136 KB | Output is correct |
114 | Correct | 206 ms | 64200 KB | Output is correct |
115 | Correct | 181 ms | 60176 KB | Output is correct |
116 | Correct | 186 ms | 60172 KB | Output is correct |
117 | Correct | 185 ms | 60412 KB | Output is correct |
118 | Correct | 184 ms | 60244 KB | Output is correct |
119 | Correct | 184 ms | 60352 KB | Output is correct |
120 | Correct | 212 ms | 64188 KB | Output is correct |
121 | Correct | 203 ms | 64016 KB | Output is correct |
122 | Correct | 206 ms | 63984 KB | Output is correct |
123 | Correct | 212 ms | 64112 KB | Output is correct |
124 | Correct | 180 ms | 68060 KB | Output is correct |
125 | Correct | 180 ms | 67948 KB | Output is correct |
126 | Correct | 179 ms | 68072 KB | Output is correct |
127 | Correct | 179 ms | 68012 KB | Output is correct |
128 | Correct | 115 ms | 34716 KB | Output is correct |
129 | Correct | 113 ms | 34780 KB | Output is correct |
130 | Correct | 111 ms | 34708 KB | Output is correct |
131 | Correct | 1 ms | 212 KB | Output is correct |