Submission #632129

# Submission time Handle Problem Language Result Execution time Memory
632129 2022-08-19T13:22:49 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 [5000010];
vector <int> g [5000010]; 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 52 ms 117720 KB Output is correct
2 Correct 53 ms 117628 KB Output is correct
3 Correct 53 ms 117728 KB Output is correct
4 Correct 52 ms 117716 KB Output is correct
5 Correct 59 ms 117708 KB Output is correct
6 Correct 52 ms 117636 KB Output is correct
7 Correct 52 ms 117604 KB Output is correct
8 Correct 52 ms 117728 KB Output is correct
9 Correct 54 ms 117708 KB Output is correct
10 Correct 53 ms 117640 KB Output is correct
11 Correct 55 ms 117664 KB Output is correct
12 Correct 53 ms 117708 KB Output is correct
13 Correct 53 ms 117708 KB Output is correct
14 Correct 57 ms 117660 KB Output is correct
15 Correct 53 ms 117620 KB Output is correct
16 Correct 53 ms 117700 KB Output is correct
17 Correct 58 ms 117672 KB Output is correct
18 Correct 53 ms 117728 KB Output is correct
19 Correct 55 ms 117744 KB Output is correct
20 Correct 57 ms 117720 KB Output is correct
21 Correct 52 ms 117632 KB Output is correct
22 Correct 52 ms 117668 KB Output is correct
23 Correct 60 ms 117712 KB Output is correct
24 Correct 52 ms 117724 KB Output is correct
25 Correct 54 ms 117708 KB Output is correct
26 Correct 53 ms 117604 KB Output is correct
27 Correct 60 ms 117720 KB Output is correct
28 Correct 54 ms 117724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 117720 KB Output is correct
2 Correct 53 ms 117628 KB Output is correct
3 Correct 53 ms 117728 KB Output is correct
4 Correct 52 ms 117716 KB Output is correct
5 Correct 59 ms 117708 KB Output is correct
6 Correct 52 ms 117636 KB Output is correct
7 Correct 52 ms 117604 KB Output is correct
8 Correct 52 ms 117728 KB Output is correct
9 Correct 54 ms 117708 KB Output is correct
10 Correct 53 ms 117640 KB Output is correct
11 Correct 55 ms 117664 KB Output is correct
12 Correct 53 ms 117708 KB Output is correct
13 Correct 53 ms 117708 KB Output is correct
14 Correct 57 ms 117660 KB Output is correct
15 Correct 53 ms 117620 KB Output is correct
16 Correct 53 ms 117700 KB Output is correct
17 Correct 58 ms 117672 KB Output is correct
18 Correct 53 ms 117728 KB Output is correct
19 Correct 55 ms 117744 KB Output is correct
20 Correct 57 ms 117720 KB Output is correct
21 Correct 52 ms 117632 KB Output is correct
22 Correct 52 ms 117668 KB Output is correct
23 Correct 60 ms 117712 KB Output is correct
24 Correct 52 ms 117724 KB Output is correct
25 Correct 54 ms 117708 KB Output is correct
26 Correct 53 ms 117604 KB Output is correct
27 Correct 60 ms 117720 KB Output is correct
28 Correct 54 ms 117724 KB Output is correct
29 Correct 53 ms 117620 KB Output is correct
30 Correct 53 ms 117716 KB Output is correct
31 Correct 54 ms 117672 KB Output is correct
32 Correct 54 ms 117656 KB Output is correct
33 Correct 52 ms 117680 KB Output is correct
34 Correct 53 ms 117680 KB Output is correct
35 Correct 69 ms 117700 KB Output is correct
36 Correct 62 ms 117644 KB Output is correct
37 Correct 57 ms 117704 KB Output is correct
38 Correct 53 ms 117684 KB Output is correct
39 Correct 58 ms 117660 KB Output is correct
40 Correct 58 ms 117624 KB Output is correct
41 Correct 58 ms 117728 KB Output is correct
42 Correct 59 ms 117676 KB Output is correct
43 Correct 54 ms 117668 KB Output is correct
44 Correct 54 ms 117664 KB Output is correct
45 Correct 56 ms 117636 KB Output is correct
46 Correct 54 ms 117728 KB Output is correct
47 Correct 53 ms 117708 KB Output is correct
48 Correct 54 ms 117668 KB Output is correct
49 Correct 53 ms 117612 KB Output is correct
50 Correct 55 ms 117728 KB Output is correct
51 Correct 53 ms 117836 KB Output is correct
52 Correct 53 ms 117700 KB Output is correct
53 Correct 53 ms 117640 KB Output is correct
54 Correct 53 ms 117708 KB Output is correct
55 Correct 54 ms 117724 KB Output is correct
56 Correct 52 ms 117612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 216 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 52 ms 117720 KB Output is correct
2 Correct 53 ms 117628 KB Output is correct
3 Correct 53 ms 117728 KB Output is correct
4 Correct 52 ms 117716 KB Output is correct
5 Correct 59 ms 117708 KB Output is correct
6 Correct 52 ms 117636 KB Output is correct
7 Correct 52 ms 117604 KB Output is correct
8 Correct 52 ms 117728 KB Output is correct
9 Correct 54 ms 117708 KB Output is correct
10 Correct 53 ms 117640 KB Output is correct
11 Correct 55 ms 117664 KB Output is correct
12 Correct 53 ms 117708 KB Output is correct
13 Correct 53 ms 117708 KB Output is correct
14 Correct 57 ms 117660 KB Output is correct
15 Correct 53 ms 117620 KB Output is correct
16 Correct 53 ms 117700 KB Output is correct
17 Correct 58 ms 117672 KB Output is correct
18 Correct 53 ms 117728 KB Output is correct
19 Correct 55 ms 117744 KB Output is correct
20 Correct 57 ms 117720 KB Output is correct
21 Correct 52 ms 117632 KB Output is correct
22 Correct 52 ms 117668 KB Output is correct
23 Correct 60 ms 117712 KB Output is correct
24 Correct 52 ms 117724 KB Output is correct
25 Correct 54 ms 117708 KB Output is correct
26 Correct 53 ms 117604 KB Output is correct
27 Correct 60 ms 117720 KB Output is correct
28 Correct 54 ms 117724 KB Output is correct
29 Correct 53 ms 117620 KB Output is correct
30 Correct 53 ms 117716 KB Output is correct
31 Correct 54 ms 117672 KB Output is correct
32 Correct 54 ms 117656 KB Output is correct
33 Correct 52 ms 117680 KB Output is correct
34 Correct 53 ms 117680 KB Output is correct
35 Correct 69 ms 117700 KB Output is correct
36 Correct 62 ms 117644 KB Output is correct
37 Correct 57 ms 117704 KB Output is correct
38 Correct 53 ms 117684 KB Output is correct
39 Correct 58 ms 117660 KB Output is correct
40 Correct 58 ms 117624 KB Output is correct
41 Correct 58 ms 117728 KB Output is correct
42 Correct 59 ms 117676 KB Output is correct
43 Correct 54 ms 117668 KB Output is correct
44 Correct 54 ms 117664 KB Output is correct
45 Correct 56 ms 117636 KB Output is correct
46 Correct 54 ms 117728 KB Output is correct
47 Correct 53 ms 117708 KB Output is correct
48 Correct 54 ms 117668 KB Output is correct
49 Correct 53 ms 117612 KB Output is correct
50 Correct 55 ms 117728 KB Output is correct
51 Correct 53 ms 117836 KB Output is correct
52 Correct 53 ms 117700 KB Output is correct
53 Correct 53 ms 117640 KB Output is correct
54 Correct 53 ms 117708 KB Output is correct
55 Correct 54 ms 117724 KB Output is correct
56 Correct 52 ms 117612 KB Output is correct
57 Correct 63 ms 117840 KB Output is correct
58 Correct 65 ms 117788 KB Output is correct
59 Correct 62 ms 117864 KB Output is correct
60 Correct 59 ms 117964 KB Output is correct
61 Correct 63 ms 117852 KB Output is correct
62 Execution timed out 1104 ms 119880 KB Time limit exceeded
63 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 52 ms 117720 KB Output is correct
2 Correct 53 ms 117628 KB Output is correct
3 Correct 53 ms 117728 KB Output is correct
4 Correct 52 ms 117716 KB Output is correct
5 Correct 59 ms 117708 KB Output is correct
6 Correct 52 ms 117636 KB Output is correct
7 Correct 52 ms 117604 KB Output is correct
8 Correct 52 ms 117728 KB Output is correct
9 Correct 54 ms 117708 KB Output is correct
10 Correct 53 ms 117640 KB Output is correct
11 Correct 55 ms 117664 KB Output is correct
12 Correct 53 ms 117708 KB Output is correct
13 Correct 53 ms 117708 KB Output is correct
14 Correct 57 ms 117660 KB Output is correct
15 Correct 53 ms 117620 KB Output is correct
16 Correct 53 ms 117700 KB Output is correct
17 Correct 58 ms 117672 KB Output is correct
18 Correct 53 ms 117728 KB Output is correct
19 Correct 55 ms 117744 KB Output is correct
20 Correct 57 ms 117720 KB Output is correct
21 Correct 52 ms 117632 KB Output is correct
22 Correct 52 ms 117668 KB Output is correct
23 Correct 60 ms 117712 KB Output is correct
24 Correct 52 ms 117724 KB Output is correct
25 Correct 54 ms 117708 KB Output is correct
26 Correct 53 ms 117604 KB Output is correct
27 Correct 60 ms 117720 KB Output is correct
28 Correct 54 ms 117724 KB Output is correct
29 Correct 53 ms 117620 KB Output is correct
30 Correct 53 ms 117716 KB Output is correct
31 Correct 54 ms 117672 KB Output is correct
32 Correct 54 ms 117656 KB Output is correct
33 Correct 52 ms 117680 KB Output is correct
34 Correct 53 ms 117680 KB Output is correct
35 Correct 69 ms 117700 KB Output is correct
36 Correct 62 ms 117644 KB Output is correct
37 Correct 57 ms 117704 KB Output is correct
38 Correct 53 ms 117684 KB Output is correct
39 Correct 58 ms 117660 KB Output is correct
40 Correct 58 ms 117624 KB Output is correct
41 Correct 58 ms 117728 KB Output is correct
42 Correct 59 ms 117676 KB Output is correct
43 Correct 54 ms 117668 KB Output is correct
44 Correct 54 ms 117664 KB Output is correct
45 Correct 56 ms 117636 KB Output is correct
46 Correct 54 ms 117728 KB Output is correct
47 Correct 53 ms 117708 KB Output is correct
48 Correct 54 ms 117668 KB Output is correct
49 Correct 53 ms 117612 KB Output is correct
50 Correct 55 ms 117728 KB Output is correct
51 Correct 53 ms 117836 KB Output is correct
52 Correct 53 ms 117700 KB Output is correct
53 Correct 53 ms 117640 KB Output is correct
54 Correct 53 ms 117708 KB Output is correct
55 Correct 54 ms 117724 KB Output is correct
56 Correct 52 ms 117612 KB Output is correct
57 Runtime error 216 ms 524288 KB Execution killed with signal 9
58 Halted 0 ms 0 KB -