Submission #632128

# Submission time Handle Problem Language Result Execution time Memory
632128 2022-08-19T13:20:37 Z drkarlicio2107 Homework (CEOI22_homework) C++14
23 / 100
1000 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
int ind=0;
int t [2000010];
vector <int> g [2000010]; int n=0; int maxi=0;
void rec (string s, int i, int par){
	maxi=max (maxi, i);
	//cout << i << endl;
	if (s [i]=='?'){
		t [ind]=2;
		g [par].push_back (ind);
		ind++; n++;
	}
	if (s [i+1]=='i'){
		t [ind]=0;
		g [par].push_back (ind);
		ind++;
		rec (s, i+4, ind-1);
	}
	if (s [i+1]=='a'){
		t [ind]=1;
		g [par].push_back (ind);
		ind++;
		rec (s, i+4, ind-1);
	}
	if (i==0) return ;
	i=maxi;
	//cout << maxi << endl;
	while (s [i]!=',') i++;
	i++;
	//cout << i << " " << ind << endl;
	maxi=max (maxi, i);
	if (s [i]=='?'){
		t [ind]=2;
		g [par].push_back (ind);
		ind++; n++;
	}
	if (s [i+1]=='i'){
		t [ind]=0;
		g [par].push_back (ind);
		ind++;
		rec (s, i+4, ind-1);
	}
	if (s [i+1]=='a'){
		t [ind]=1;
		g [par].push_back (ind);
		ind++;
		rec (s, i+4, ind-1);
	}
	return ;
}
pair <int, int> sol (int x){
	if (t [x]==2) return {1, n};
	int l1=sol (g[x][0]).first; int l2=sol (g[x][1]).first; int r1=sol (g[x][0]).second; int r2=sol (g[x][1]).second;
	if (t [x]==1) return {l1+l2, max (r1, r2)};
	return {min (l1, l2), r1+r2-n-1};
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
	string s; cin >> s;
	rec (s, 0, 2000001);
	//cout << g [0].size();
	cout << sol (0).second-sol (0).first+1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 47188 KB Output is correct
2 Correct 23 ms 47264 KB Output is correct
3 Correct 21 ms 47220 KB Output is correct
4 Correct 23 ms 47292 KB Output is correct
5 Correct 22 ms 47204 KB Output is correct
6 Correct 22 ms 47188 KB Output is correct
7 Correct 24 ms 47208 KB Output is correct
8 Correct 22 ms 47168 KB Output is correct
9 Correct 22 ms 47188 KB Output is correct
10 Correct 23 ms 47188 KB Output is correct
11 Correct 26 ms 47196 KB Output is correct
12 Correct 29 ms 47188 KB Output is correct
13 Correct 22 ms 47188 KB Output is correct
14 Correct 23 ms 47164 KB Output is correct
15 Correct 23 ms 47276 KB Output is correct
16 Correct 22 ms 47280 KB Output is correct
17 Correct 23 ms 47216 KB Output is correct
18 Correct 23 ms 47232 KB Output is correct
19 Correct 26 ms 47244 KB Output is correct
20 Correct 27 ms 47272 KB Output is correct
21 Correct 23 ms 47292 KB Output is correct
22 Correct 28 ms 47200 KB Output is correct
23 Correct 27 ms 47292 KB Output is correct
24 Correct 28 ms 47228 KB Output is correct
25 Correct 25 ms 47204 KB Output is correct
26 Correct 24 ms 47236 KB Output is correct
27 Correct 25 ms 47188 KB Output is correct
28 Correct 26 ms 47176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 47188 KB Output is correct
2 Correct 23 ms 47264 KB Output is correct
3 Correct 21 ms 47220 KB Output is correct
4 Correct 23 ms 47292 KB Output is correct
5 Correct 22 ms 47204 KB Output is correct
6 Correct 22 ms 47188 KB Output is correct
7 Correct 24 ms 47208 KB Output is correct
8 Correct 22 ms 47168 KB Output is correct
9 Correct 22 ms 47188 KB Output is correct
10 Correct 23 ms 47188 KB Output is correct
11 Correct 26 ms 47196 KB Output is correct
12 Correct 29 ms 47188 KB Output is correct
13 Correct 22 ms 47188 KB Output is correct
14 Correct 23 ms 47164 KB Output is correct
15 Correct 23 ms 47276 KB Output is correct
16 Correct 22 ms 47280 KB Output is correct
17 Correct 23 ms 47216 KB Output is correct
18 Correct 23 ms 47232 KB Output is correct
19 Correct 26 ms 47244 KB Output is correct
20 Correct 27 ms 47272 KB Output is correct
21 Correct 23 ms 47292 KB Output is correct
22 Correct 28 ms 47200 KB Output is correct
23 Correct 27 ms 47292 KB Output is correct
24 Correct 28 ms 47228 KB Output is correct
25 Correct 25 ms 47204 KB Output is correct
26 Correct 24 ms 47236 KB Output is correct
27 Correct 25 ms 47188 KB Output is correct
28 Correct 26 ms 47176 KB Output is correct
29 Correct 23 ms 47180 KB Output is correct
30 Correct 24 ms 47208 KB Output is correct
31 Correct 24 ms 47292 KB Output is correct
32 Correct 27 ms 47232 KB Output is correct
33 Correct 23 ms 47260 KB Output is correct
34 Correct 24 ms 47276 KB Output is correct
35 Correct 23 ms 47392 KB Output is correct
36 Correct 23 ms 47188 KB Output is correct
37 Correct 27 ms 47196 KB Output is correct
38 Correct 24 ms 47248 KB Output is correct
39 Correct 27 ms 47236 KB Output is correct
40 Correct 24 ms 47188 KB Output is correct
41 Correct 26 ms 47284 KB Output is correct
42 Correct 24 ms 47268 KB Output is correct
43 Correct 25 ms 47260 KB Output is correct
44 Correct 27 ms 47188 KB Output is correct
45 Correct 25 ms 47204 KB Output is correct
46 Correct 29 ms 47188 KB Output is correct
47 Correct 23 ms 47292 KB Output is correct
48 Correct 23 ms 47188 KB Output is correct
49 Correct 23 ms 47228 KB Output is correct
50 Correct 23 ms 47188 KB Output is correct
51 Correct 23 ms 47256 KB Output is correct
52 Correct 23 ms 47180 KB Output is correct
53 Correct 25 ms 47168 KB Output is correct
54 Correct 23 ms 47188 KB Output is correct
55 Correct 22 ms 47200 KB Output is correct
56 Correct 25 ms 47184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 220 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 47188 KB Output is correct
2 Correct 23 ms 47264 KB Output is correct
3 Correct 21 ms 47220 KB Output is correct
4 Correct 23 ms 47292 KB Output is correct
5 Correct 22 ms 47204 KB Output is correct
6 Correct 22 ms 47188 KB Output is correct
7 Correct 24 ms 47208 KB Output is correct
8 Correct 22 ms 47168 KB Output is correct
9 Correct 22 ms 47188 KB Output is correct
10 Correct 23 ms 47188 KB Output is correct
11 Correct 26 ms 47196 KB Output is correct
12 Correct 29 ms 47188 KB Output is correct
13 Correct 22 ms 47188 KB Output is correct
14 Correct 23 ms 47164 KB Output is correct
15 Correct 23 ms 47276 KB Output is correct
16 Correct 22 ms 47280 KB Output is correct
17 Correct 23 ms 47216 KB Output is correct
18 Correct 23 ms 47232 KB Output is correct
19 Correct 26 ms 47244 KB Output is correct
20 Correct 27 ms 47272 KB Output is correct
21 Correct 23 ms 47292 KB Output is correct
22 Correct 28 ms 47200 KB Output is correct
23 Correct 27 ms 47292 KB Output is correct
24 Correct 28 ms 47228 KB Output is correct
25 Correct 25 ms 47204 KB Output is correct
26 Correct 24 ms 47236 KB Output is correct
27 Correct 25 ms 47188 KB Output is correct
28 Correct 26 ms 47176 KB Output is correct
29 Correct 23 ms 47180 KB Output is correct
30 Correct 24 ms 47208 KB Output is correct
31 Correct 24 ms 47292 KB Output is correct
32 Correct 27 ms 47232 KB Output is correct
33 Correct 23 ms 47260 KB Output is correct
34 Correct 24 ms 47276 KB Output is correct
35 Correct 23 ms 47392 KB Output is correct
36 Correct 23 ms 47188 KB Output is correct
37 Correct 27 ms 47196 KB Output is correct
38 Correct 24 ms 47248 KB Output is correct
39 Correct 27 ms 47236 KB Output is correct
40 Correct 24 ms 47188 KB Output is correct
41 Correct 26 ms 47284 KB Output is correct
42 Correct 24 ms 47268 KB Output is correct
43 Correct 25 ms 47260 KB Output is correct
44 Correct 27 ms 47188 KB Output is correct
45 Correct 25 ms 47204 KB Output is correct
46 Correct 29 ms 47188 KB Output is correct
47 Correct 23 ms 47292 KB Output is correct
48 Correct 23 ms 47188 KB Output is correct
49 Correct 23 ms 47228 KB Output is correct
50 Correct 23 ms 47188 KB Output is correct
51 Correct 23 ms 47256 KB Output is correct
52 Correct 23 ms 47180 KB Output is correct
53 Correct 25 ms 47168 KB Output is correct
54 Correct 23 ms 47188 KB Output is correct
55 Correct 22 ms 47200 KB Output is correct
56 Correct 25 ms 47184 KB Output is correct
57 Correct 37 ms 47356 KB Output is correct
58 Correct 33 ms 47316 KB Output is correct
59 Correct 30 ms 47316 KB Output is correct
60 Correct 30 ms 47432 KB Output is correct
61 Correct 44 ms 47312 KB Output is correct
62 Execution timed out 1095 ms 49440 KB Time limit exceeded
63 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 47188 KB Output is correct
2 Correct 23 ms 47264 KB Output is correct
3 Correct 21 ms 47220 KB Output is correct
4 Correct 23 ms 47292 KB Output is correct
5 Correct 22 ms 47204 KB Output is correct
6 Correct 22 ms 47188 KB Output is correct
7 Correct 24 ms 47208 KB Output is correct
8 Correct 22 ms 47168 KB Output is correct
9 Correct 22 ms 47188 KB Output is correct
10 Correct 23 ms 47188 KB Output is correct
11 Correct 26 ms 47196 KB Output is correct
12 Correct 29 ms 47188 KB Output is correct
13 Correct 22 ms 47188 KB Output is correct
14 Correct 23 ms 47164 KB Output is correct
15 Correct 23 ms 47276 KB Output is correct
16 Correct 22 ms 47280 KB Output is correct
17 Correct 23 ms 47216 KB Output is correct
18 Correct 23 ms 47232 KB Output is correct
19 Correct 26 ms 47244 KB Output is correct
20 Correct 27 ms 47272 KB Output is correct
21 Correct 23 ms 47292 KB Output is correct
22 Correct 28 ms 47200 KB Output is correct
23 Correct 27 ms 47292 KB Output is correct
24 Correct 28 ms 47228 KB Output is correct
25 Correct 25 ms 47204 KB Output is correct
26 Correct 24 ms 47236 KB Output is correct
27 Correct 25 ms 47188 KB Output is correct
28 Correct 26 ms 47176 KB Output is correct
29 Correct 23 ms 47180 KB Output is correct
30 Correct 24 ms 47208 KB Output is correct
31 Correct 24 ms 47292 KB Output is correct
32 Correct 27 ms 47232 KB Output is correct
33 Correct 23 ms 47260 KB Output is correct
34 Correct 24 ms 47276 KB Output is correct
35 Correct 23 ms 47392 KB Output is correct
36 Correct 23 ms 47188 KB Output is correct
37 Correct 27 ms 47196 KB Output is correct
38 Correct 24 ms 47248 KB Output is correct
39 Correct 27 ms 47236 KB Output is correct
40 Correct 24 ms 47188 KB Output is correct
41 Correct 26 ms 47284 KB Output is correct
42 Correct 24 ms 47268 KB Output is correct
43 Correct 25 ms 47260 KB Output is correct
44 Correct 27 ms 47188 KB Output is correct
45 Correct 25 ms 47204 KB Output is correct
46 Correct 29 ms 47188 KB Output is correct
47 Correct 23 ms 47292 KB Output is correct
48 Correct 23 ms 47188 KB Output is correct
49 Correct 23 ms 47228 KB Output is correct
50 Correct 23 ms 47188 KB Output is correct
51 Correct 23 ms 47256 KB Output is correct
52 Correct 23 ms 47180 KB Output is correct
53 Correct 25 ms 47168 KB Output is correct
54 Correct 23 ms 47188 KB Output is correct
55 Correct 22 ms 47200 KB Output is correct
56 Correct 25 ms 47184 KB Output is correct
57 Runtime error 220 ms 524288 KB Execution killed with signal 9
58 Halted 0 ms 0 KB -