Submission #632135

# Submission time Handle Problem Language Result Execution time Memory
632135 2022-08-19T13:38:51 Z drkarlicio2107 Homework (CEOI22_homework) C++14
23 / 100
1000 ms 242252 KB
#include <bits/stdc++.h>
using namespace std;
int ind=0;
int t [5000010];
vector <int> g [5000010]; int n=0; int maxi=0; string s;
void rec (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 (i+4, ind-1);
	}
	if (s [i+1]=='a'){
		t [ind]=1;
		g [par].push_back (ind);
		ind++;
		rec (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 (i+4, ind-1);
	}
	if (s [i+1]=='a'){
		t [ind]=1;
		g [par].push_back (ind);
		ind++;
		rec (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); 
	cin >> s;
	rec (0, 5000001);
	//cout << g [0].size();
	cout << sol (0).second-sol (0).first+1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 54 ms 117708 KB Output is correct
2 Correct 52 ms 117708 KB Output is correct
3 Correct 53 ms 117608 KB Output is correct
4 Correct 54 ms 117720 KB Output is correct
5 Correct 54 ms 117708 KB Output is correct
6 Correct 56 ms 117788 KB Output is correct
7 Correct 59 ms 117724 KB Output is correct
8 Correct 60 ms 117652 KB Output is correct
9 Correct 56 ms 117648 KB Output is correct
10 Correct 55 ms 117664 KB Output is correct
11 Correct 53 ms 117708 KB Output is correct
12 Correct 56 ms 117680 KB Output is correct
13 Correct 54 ms 117708 KB Output is correct
14 Correct 56 ms 117616 KB Output is correct
15 Correct 57 ms 117640 KB Output is correct
16 Correct 61 ms 117784 KB Output is correct
17 Correct 53 ms 117708 KB Output is correct
18 Correct 59 ms 117596 KB Output is correct
19 Correct 54 ms 117708 KB Output is correct
20 Correct 53 ms 117680 KB Output is correct
21 Correct 57 ms 117720 KB Output is correct
22 Correct 55 ms 117600 KB Output is correct
23 Correct 55 ms 117724 KB Output is correct
24 Correct 63 ms 117616 KB Output is correct
25 Correct 64 ms 117704 KB Output is correct
26 Correct 54 ms 117708 KB Output is correct
27 Correct 54 ms 117724 KB Output is correct
28 Correct 53 ms 117708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 117708 KB Output is correct
2 Correct 52 ms 117708 KB Output is correct
3 Correct 53 ms 117608 KB Output is correct
4 Correct 54 ms 117720 KB Output is correct
5 Correct 54 ms 117708 KB Output is correct
6 Correct 56 ms 117788 KB Output is correct
7 Correct 59 ms 117724 KB Output is correct
8 Correct 60 ms 117652 KB Output is correct
9 Correct 56 ms 117648 KB Output is correct
10 Correct 55 ms 117664 KB Output is correct
11 Correct 53 ms 117708 KB Output is correct
12 Correct 56 ms 117680 KB Output is correct
13 Correct 54 ms 117708 KB Output is correct
14 Correct 56 ms 117616 KB Output is correct
15 Correct 57 ms 117640 KB Output is correct
16 Correct 61 ms 117784 KB Output is correct
17 Correct 53 ms 117708 KB Output is correct
18 Correct 59 ms 117596 KB Output is correct
19 Correct 54 ms 117708 KB Output is correct
20 Correct 53 ms 117680 KB Output is correct
21 Correct 57 ms 117720 KB Output is correct
22 Correct 55 ms 117600 KB Output is correct
23 Correct 55 ms 117724 KB Output is correct
24 Correct 63 ms 117616 KB Output is correct
25 Correct 64 ms 117704 KB Output is correct
26 Correct 54 ms 117708 KB Output is correct
27 Correct 54 ms 117724 KB Output is correct
28 Correct 53 ms 117708 KB Output is correct
29 Correct 54 ms 117700 KB Output is correct
30 Correct 54 ms 117720 KB Output is correct
31 Correct 54 ms 117628 KB Output is correct
32 Correct 55 ms 117660 KB Output is correct
33 Correct 54 ms 117708 KB Output is correct
34 Correct 55 ms 117616 KB Output is correct
35 Correct 55 ms 117636 KB Output is correct
36 Correct 55 ms 117724 KB Output is correct
37 Correct 53 ms 117708 KB Output is correct
38 Correct 54 ms 117640 KB Output is correct
39 Correct 58 ms 117688 KB Output is correct
40 Correct 55 ms 117652 KB Output is correct
41 Correct 57 ms 117708 KB Output is correct
42 Correct 54 ms 117660 KB Output is correct
43 Correct 55 ms 117624 KB Output is correct
44 Correct 57 ms 117652 KB Output is correct
45 Correct 54 ms 117720 KB Output is correct
46 Correct 60 ms 117708 KB Output is correct
47 Correct 59 ms 117708 KB Output is correct
48 Correct 56 ms 117660 KB Output is correct
49 Correct 55 ms 117724 KB Output is correct
50 Correct 55 ms 117708 KB Output is correct
51 Correct 56 ms 117632 KB Output is correct
52 Correct 54 ms 117700 KB Output is correct
53 Correct 54 ms 117608 KB Output is correct
54 Correct 54 ms 117660 KB Output is correct
55 Correct 64 ms 117708 KB Output is correct
56 Correct 54 ms 117608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1029 ms 242252 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 117708 KB Output is correct
2 Correct 52 ms 117708 KB Output is correct
3 Correct 53 ms 117608 KB Output is correct
4 Correct 54 ms 117720 KB Output is correct
5 Correct 54 ms 117708 KB Output is correct
6 Correct 56 ms 117788 KB Output is correct
7 Correct 59 ms 117724 KB Output is correct
8 Correct 60 ms 117652 KB Output is correct
9 Correct 56 ms 117648 KB Output is correct
10 Correct 55 ms 117664 KB Output is correct
11 Correct 53 ms 117708 KB Output is correct
12 Correct 56 ms 117680 KB Output is correct
13 Correct 54 ms 117708 KB Output is correct
14 Correct 56 ms 117616 KB Output is correct
15 Correct 57 ms 117640 KB Output is correct
16 Correct 61 ms 117784 KB Output is correct
17 Correct 53 ms 117708 KB Output is correct
18 Correct 59 ms 117596 KB Output is correct
19 Correct 54 ms 117708 KB Output is correct
20 Correct 53 ms 117680 KB Output is correct
21 Correct 57 ms 117720 KB Output is correct
22 Correct 55 ms 117600 KB Output is correct
23 Correct 55 ms 117724 KB Output is correct
24 Correct 63 ms 117616 KB Output is correct
25 Correct 64 ms 117704 KB Output is correct
26 Correct 54 ms 117708 KB Output is correct
27 Correct 54 ms 117724 KB Output is correct
28 Correct 53 ms 117708 KB Output is correct
29 Correct 54 ms 117700 KB Output is correct
30 Correct 54 ms 117720 KB Output is correct
31 Correct 54 ms 117628 KB Output is correct
32 Correct 55 ms 117660 KB Output is correct
33 Correct 54 ms 117708 KB Output is correct
34 Correct 55 ms 117616 KB Output is correct
35 Correct 55 ms 117636 KB Output is correct
36 Correct 55 ms 117724 KB Output is correct
37 Correct 53 ms 117708 KB Output is correct
38 Correct 54 ms 117640 KB Output is correct
39 Correct 58 ms 117688 KB Output is correct
40 Correct 55 ms 117652 KB Output is correct
41 Correct 57 ms 117708 KB Output is correct
42 Correct 54 ms 117660 KB Output is correct
43 Correct 55 ms 117624 KB Output is correct
44 Correct 57 ms 117652 KB Output is correct
45 Correct 54 ms 117720 KB Output is correct
46 Correct 60 ms 117708 KB Output is correct
47 Correct 59 ms 117708 KB Output is correct
48 Correct 56 ms 117660 KB Output is correct
49 Correct 55 ms 117724 KB Output is correct
50 Correct 55 ms 117708 KB Output is correct
51 Correct 56 ms 117632 KB Output is correct
52 Correct 54 ms 117700 KB Output is correct
53 Correct 54 ms 117608 KB Output is correct
54 Correct 54 ms 117660 KB Output is correct
55 Correct 64 ms 117708 KB Output is correct
56 Correct 54 ms 117608 KB Output is correct
57 Correct 59 ms 117708 KB Output is correct
58 Correct 67 ms 117708 KB Output is correct
59 Correct 59 ms 117756 KB Output is correct
60 Correct 65 ms 117772 KB Output is correct
61 Correct 61 ms 117756 KB Output is correct
62 Execution timed out 1090 ms 117688 KB Time limit exceeded
63 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 117708 KB Output is correct
2 Correct 52 ms 117708 KB Output is correct
3 Correct 53 ms 117608 KB Output is correct
4 Correct 54 ms 117720 KB Output is correct
5 Correct 54 ms 117708 KB Output is correct
6 Correct 56 ms 117788 KB Output is correct
7 Correct 59 ms 117724 KB Output is correct
8 Correct 60 ms 117652 KB Output is correct
9 Correct 56 ms 117648 KB Output is correct
10 Correct 55 ms 117664 KB Output is correct
11 Correct 53 ms 117708 KB Output is correct
12 Correct 56 ms 117680 KB Output is correct
13 Correct 54 ms 117708 KB Output is correct
14 Correct 56 ms 117616 KB Output is correct
15 Correct 57 ms 117640 KB Output is correct
16 Correct 61 ms 117784 KB Output is correct
17 Correct 53 ms 117708 KB Output is correct
18 Correct 59 ms 117596 KB Output is correct
19 Correct 54 ms 117708 KB Output is correct
20 Correct 53 ms 117680 KB Output is correct
21 Correct 57 ms 117720 KB Output is correct
22 Correct 55 ms 117600 KB Output is correct
23 Correct 55 ms 117724 KB Output is correct
24 Correct 63 ms 117616 KB Output is correct
25 Correct 64 ms 117704 KB Output is correct
26 Correct 54 ms 117708 KB Output is correct
27 Correct 54 ms 117724 KB Output is correct
28 Correct 53 ms 117708 KB Output is correct
29 Correct 54 ms 117700 KB Output is correct
30 Correct 54 ms 117720 KB Output is correct
31 Correct 54 ms 117628 KB Output is correct
32 Correct 55 ms 117660 KB Output is correct
33 Correct 54 ms 117708 KB Output is correct
34 Correct 55 ms 117616 KB Output is correct
35 Correct 55 ms 117636 KB Output is correct
36 Correct 55 ms 117724 KB Output is correct
37 Correct 53 ms 117708 KB Output is correct
38 Correct 54 ms 117640 KB Output is correct
39 Correct 58 ms 117688 KB Output is correct
40 Correct 55 ms 117652 KB Output is correct
41 Correct 57 ms 117708 KB Output is correct
42 Correct 54 ms 117660 KB Output is correct
43 Correct 55 ms 117624 KB Output is correct
44 Correct 57 ms 117652 KB Output is correct
45 Correct 54 ms 117720 KB Output is correct
46 Correct 60 ms 117708 KB Output is correct
47 Correct 59 ms 117708 KB Output is correct
48 Correct 56 ms 117660 KB Output is correct
49 Correct 55 ms 117724 KB Output is correct
50 Correct 55 ms 117708 KB Output is correct
51 Correct 56 ms 117632 KB Output is correct
52 Correct 54 ms 117700 KB Output is correct
53 Correct 54 ms 117608 KB Output is correct
54 Correct 54 ms 117660 KB Output is correct
55 Correct 64 ms 117708 KB Output is correct
56 Correct 54 ms 117608 KB Output is correct
57 Execution timed out 1029 ms 242252 KB Time limit exceeded
58 Halted 0 ms 0 KB -