답안 #1058740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1058740 2024-08-14T13:15:22 Z Warinchai Homework (CEOI22_homework) C++14
100 / 100
79 ms 180428 KB
#include<bits/stdc++.h>
using namespace std;
int type[1000005];
string s;
struct node{
    int st,en,sz;
    node(int _st=0,int _en=0,int _sz=0){
        st=_st,en=_en,sz=_sz;
    }
    friend node operator+(node a,node b){
        node c;
        c.st=a.st+b.st;
        c.en=max(a.en+b.sz,b.en+a.sz);
        c.sz=a.sz+b.sz;
        return c;
    }
    friend node operator-(node a,node b){
        node c;
        c.st=min(a.st,b.st);
        c.en=a.en+b.en-1;
        c.sz=a.sz+b.sz;
        return c;
    }
}info[10000005];
int cur=0;
int dfs(int u,int st){
    if(s[st]=='?'){
        info[u]=node(1,1,1);
        //cerr<<u<<":leaf\n";
        //cerr<<"vals:"<<info[u].st<<" "<<info[u].en<<" "<<info[u].sz<<"\n";
        return st;
    }else if(s[st+1]=='i'){
        int id1=cur+1;
        int st1=st+4;
        int en1=dfs(++cur,st1);
        int id2=cur+1;
        int st2=en1+2;
        int en2=dfs(++cur,st2);
        info[u]=info[id1]-info[id2];
        //cerr<<u<<":"<<id1<<" "<<id2<<"\n";
        //cerr<<"vals:"<<info[u].st<<" "<<info[u].en<<" "<<info[u].sz<<"\n";
        return en2+1;
    }else{
        int id1=cur+1;
        int st1=st+4;
        int en1=dfs(++cur,st1);
        int id2=cur+1;
        int st2=en1+2;
        int en2=dfs(++cur,st2);
        info[u]=info[id1]+info[id2];
        //cerr<<u<<":"<<id1<<" "<<id2<<"\n";
        //cerr<<"vals:"<<info[u].st<<" "<<info[u].en<<" "<<info[u].sz<<"\n";
        return en2+1;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    dfs(++cur,0);
    cout<<info[1].en-info[1].st+1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 119644 KB Output is correct
2 Correct 18 ms 119824 KB Output is correct
3 Correct 19 ms 119644 KB Output is correct
4 Correct 18 ms 119572 KB Output is correct
5 Correct 18 ms 119644 KB Output is correct
6 Correct 18 ms 119644 KB Output is correct
7 Correct 18 ms 119644 KB Output is correct
8 Correct 18 ms 119644 KB Output is correct
9 Correct 21 ms 119544 KB Output is correct
10 Correct 19 ms 119644 KB Output is correct
11 Correct 18 ms 119496 KB Output is correct
12 Correct 18 ms 119644 KB Output is correct
13 Correct 18 ms 119644 KB Output is correct
14 Correct 18 ms 119644 KB Output is correct
15 Correct 19 ms 119556 KB Output is correct
16 Correct 19 ms 119628 KB Output is correct
17 Correct 18 ms 119560 KB Output is correct
18 Correct 18 ms 119644 KB Output is correct
19 Correct 18 ms 119380 KB Output is correct
20 Correct 18 ms 119556 KB Output is correct
21 Correct 19 ms 119644 KB Output is correct
22 Correct 19 ms 119632 KB Output is correct
23 Correct 18 ms 119644 KB Output is correct
24 Correct 18 ms 119644 KB Output is correct
25 Correct 18 ms 119644 KB Output is correct
26 Correct 18 ms 119644 KB Output is correct
27 Correct 18 ms 119500 KB Output is correct
28 Correct 20 ms 119644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 119644 KB Output is correct
2 Correct 18 ms 119824 KB Output is correct
3 Correct 19 ms 119644 KB Output is correct
4 Correct 18 ms 119572 KB Output is correct
5 Correct 18 ms 119644 KB Output is correct
6 Correct 18 ms 119644 KB Output is correct
7 Correct 18 ms 119644 KB Output is correct
8 Correct 18 ms 119644 KB Output is correct
9 Correct 21 ms 119544 KB Output is correct
10 Correct 19 ms 119644 KB Output is correct
11 Correct 18 ms 119496 KB Output is correct
12 Correct 18 ms 119644 KB Output is correct
13 Correct 18 ms 119644 KB Output is correct
14 Correct 18 ms 119644 KB Output is correct
15 Correct 19 ms 119556 KB Output is correct
16 Correct 19 ms 119628 KB Output is correct
17 Correct 18 ms 119560 KB Output is correct
18 Correct 18 ms 119644 KB Output is correct
19 Correct 18 ms 119380 KB Output is correct
20 Correct 18 ms 119556 KB Output is correct
21 Correct 19 ms 119644 KB Output is correct
22 Correct 19 ms 119632 KB Output is correct
23 Correct 18 ms 119644 KB Output is correct
24 Correct 18 ms 119644 KB Output is correct
25 Correct 18 ms 119644 KB Output is correct
26 Correct 18 ms 119644 KB Output is correct
27 Correct 18 ms 119500 KB Output is correct
28 Correct 20 ms 119644 KB Output is correct
29 Correct 19 ms 119644 KB Output is correct
30 Correct 20 ms 119612 KB Output is correct
31 Correct 18 ms 119644 KB Output is correct
32 Correct 18 ms 119644 KB Output is correct
33 Correct 18 ms 119552 KB Output is correct
34 Correct 18 ms 119496 KB Output is correct
35 Correct 19 ms 119644 KB Output is correct
36 Correct 19 ms 119644 KB Output is correct
37 Correct 18 ms 119436 KB Output is correct
38 Correct 21 ms 119644 KB Output is correct
39 Correct 18 ms 119644 KB Output is correct
40 Correct 18 ms 119424 KB Output is correct
41 Correct 18 ms 119440 KB Output is correct
42 Correct 20 ms 119564 KB Output is correct
43 Correct 18 ms 119644 KB Output is correct
44 Correct 19 ms 119644 KB Output is correct
45 Correct 19 ms 119644 KB Output is correct
46 Correct 18 ms 119644 KB Output is correct
47 Correct 18 ms 119640 KB Output is correct
48 Correct 23 ms 119644 KB Output is correct
49 Correct 18 ms 119552 KB Output is correct
50 Correct 18 ms 119648 KB Output is correct
51 Correct 18 ms 119644 KB Output is correct
52 Correct 18 ms 119484 KB Output is correct
53 Correct 18 ms 119504 KB Output is correct
54 Correct 18 ms 119644 KB Output is correct
55 Correct 18 ms 119556 KB Output is correct
56 Correct 18 ms 119644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 180172 KB Output is correct
2 Correct 63 ms 180180 KB Output is correct
3 Correct 65 ms 180168 KB Output is correct
4 Correct 73 ms 180364 KB Output is correct
5 Correct 66 ms 180424 KB Output is correct
6 Correct 64 ms 180204 KB Output is correct
7 Correct 65 ms 180428 KB Output is correct
8 Correct 62 ms 180172 KB Output is correct
9 Correct 64 ms 180172 KB Output is correct
10 Correct 67 ms 180172 KB Output is correct
11 Correct 63 ms 180420 KB Output is correct
12 Correct 79 ms 180176 KB Output is correct
13 Correct 19 ms 119644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 119644 KB Output is correct
2 Correct 18 ms 119824 KB Output is correct
3 Correct 19 ms 119644 KB Output is correct
4 Correct 18 ms 119572 KB Output is correct
5 Correct 18 ms 119644 KB Output is correct
6 Correct 18 ms 119644 KB Output is correct
7 Correct 18 ms 119644 KB Output is correct
8 Correct 18 ms 119644 KB Output is correct
9 Correct 21 ms 119544 KB Output is correct
10 Correct 19 ms 119644 KB Output is correct
11 Correct 18 ms 119496 KB Output is correct
12 Correct 18 ms 119644 KB Output is correct
13 Correct 18 ms 119644 KB Output is correct
14 Correct 18 ms 119644 KB Output is correct
15 Correct 19 ms 119556 KB Output is correct
16 Correct 19 ms 119628 KB Output is correct
17 Correct 18 ms 119560 KB Output is correct
18 Correct 18 ms 119644 KB Output is correct
19 Correct 18 ms 119380 KB Output is correct
20 Correct 18 ms 119556 KB Output is correct
21 Correct 19 ms 119644 KB Output is correct
22 Correct 19 ms 119632 KB Output is correct
23 Correct 18 ms 119644 KB Output is correct
24 Correct 18 ms 119644 KB Output is correct
25 Correct 18 ms 119644 KB Output is correct
26 Correct 18 ms 119644 KB Output is correct
27 Correct 18 ms 119500 KB Output is correct
28 Correct 20 ms 119644 KB Output is correct
29 Correct 19 ms 119644 KB Output is correct
30 Correct 20 ms 119612 KB Output is correct
31 Correct 18 ms 119644 KB Output is correct
32 Correct 18 ms 119644 KB Output is correct
33 Correct 18 ms 119552 KB Output is correct
34 Correct 18 ms 119496 KB Output is correct
35 Correct 19 ms 119644 KB Output is correct
36 Correct 19 ms 119644 KB Output is correct
37 Correct 18 ms 119436 KB Output is correct
38 Correct 21 ms 119644 KB Output is correct
39 Correct 18 ms 119644 KB Output is correct
40 Correct 18 ms 119424 KB Output is correct
41 Correct 18 ms 119440 KB Output is correct
42 Correct 20 ms 119564 KB Output is correct
43 Correct 18 ms 119644 KB Output is correct
44 Correct 19 ms 119644 KB Output is correct
45 Correct 19 ms 119644 KB Output is correct
46 Correct 18 ms 119644 KB Output is correct
47 Correct 18 ms 119640 KB Output is correct
48 Correct 23 ms 119644 KB Output is correct
49 Correct 18 ms 119552 KB Output is correct
50 Correct 18 ms 119648 KB Output is correct
51 Correct 18 ms 119644 KB Output is correct
52 Correct 18 ms 119484 KB Output is correct
53 Correct 18 ms 119504 KB Output is correct
54 Correct 18 ms 119644 KB Output is correct
55 Correct 18 ms 119556 KB Output is correct
56 Correct 18 ms 119644 KB Output is correct
57 Correct 19 ms 119644 KB Output is correct
58 Correct 19 ms 119644 KB Output is correct
59 Correct 18 ms 119640 KB Output is correct
60 Correct 19 ms 119644 KB Output is correct
61 Correct 19 ms 119640 KB Output is correct
62 Correct 19 ms 119644 KB Output is correct
63 Correct 20 ms 119644 KB Output is correct
64 Correct 21 ms 119608 KB Output is correct
65 Correct 18 ms 119644 KB Output is correct
66 Correct 18 ms 119644 KB Output is correct
67 Correct 19 ms 119644 KB Output is correct
68 Correct 20 ms 119644 KB Output is correct
69 Correct 19 ms 119644 KB Output is correct
70 Correct 19 ms 119456 KB Output is correct
71 Correct 19 ms 119536 KB Output is correct
72 Correct 19 ms 119484 KB Output is correct
73 Correct 19 ms 119636 KB Output is correct
74 Correct 18 ms 119644 KB Output is correct
75 Correct 19 ms 119548 KB Output is correct
76 Correct 18 ms 119644 KB Output is correct
77 Correct 20 ms 119644 KB Output is correct
78 Correct 19 ms 119516 KB Output is correct
79 Correct 19 ms 119644 KB Output is correct
80 Correct 19 ms 119644 KB Output is correct
81 Correct 19 ms 119644 KB Output is correct
82 Correct 19 ms 119644 KB Output is correct
83 Correct 19 ms 119644 KB Output is correct
84 Correct 19 ms 119572 KB Output is correct
85 Correct 19 ms 119644 KB Output is correct
86 Correct 19 ms 119480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 119644 KB Output is correct
2 Correct 18 ms 119824 KB Output is correct
3 Correct 19 ms 119644 KB Output is correct
4 Correct 18 ms 119572 KB Output is correct
5 Correct 18 ms 119644 KB Output is correct
6 Correct 18 ms 119644 KB Output is correct
7 Correct 18 ms 119644 KB Output is correct
8 Correct 18 ms 119644 KB Output is correct
9 Correct 21 ms 119544 KB Output is correct
10 Correct 19 ms 119644 KB Output is correct
11 Correct 18 ms 119496 KB Output is correct
12 Correct 18 ms 119644 KB Output is correct
13 Correct 18 ms 119644 KB Output is correct
14 Correct 18 ms 119644 KB Output is correct
15 Correct 19 ms 119556 KB Output is correct
16 Correct 19 ms 119628 KB Output is correct
17 Correct 18 ms 119560 KB Output is correct
18 Correct 18 ms 119644 KB Output is correct
19 Correct 18 ms 119380 KB Output is correct
20 Correct 18 ms 119556 KB Output is correct
21 Correct 19 ms 119644 KB Output is correct
22 Correct 19 ms 119632 KB Output is correct
23 Correct 18 ms 119644 KB Output is correct
24 Correct 18 ms 119644 KB Output is correct
25 Correct 18 ms 119644 KB Output is correct
26 Correct 18 ms 119644 KB Output is correct
27 Correct 18 ms 119500 KB Output is correct
28 Correct 20 ms 119644 KB Output is correct
29 Correct 19 ms 119644 KB Output is correct
30 Correct 20 ms 119612 KB Output is correct
31 Correct 18 ms 119644 KB Output is correct
32 Correct 18 ms 119644 KB Output is correct
33 Correct 18 ms 119552 KB Output is correct
34 Correct 18 ms 119496 KB Output is correct
35 Correct 19 ms 119644 KB Output is correct
36 Correct 19 ms 119644 KB Output is correct
37 Correct 18 ms 119436 KB Output is correct
38 Correct 21 ms 119644 KB Output is correct
39 Correct 18 ms 119644 KB Output is correct
40 Correct 18 ms 119424 KB Output is correct
41 Correct 18 ms 119440 KB Output is correct
42 Correct 20 ms 119564 KB Output is correct
43 Correct 18 ms 119644 KB Output is correct
44 Correct 19 ms 119644 KB Output is correct
45 Correct 19 ms 119644 KB Output is correct
46 Correct 18 ms 119644 KB Output is correct
47 Correct 18 ms 119640 KB Output is correct
48 Correct 23 ms 119644 KB Output is correct
49 Correct 18 ms 119552 KB Output is correct
50 Correct 18 ms 119648 KB Output is correct
51 Correct 18 ms 119644 KB Output is correct
52 Correct 18 ms 119484 KB Output is correct
53 Correct 18 ms 119504 KB Output is correct
54 Correct 18 ms 119644 KB Output is correct
55 Correct 18 ms 119556 KB Output is correct
56 Correct 18 ms 119644 KB Output is correct
57 Correct 68 ms 180172 KB Output is correct
58 Correct 63 ms 180180 KB Output is correct
59 Correct 65 ms 180168 KB Output is correct
60 Correct 73 ms 180364 KB Output is correct
61 Correct 66 ms 180424 KB Output is correct
62 Correct 64 ms 180204 KB Output is correct
63 Correct 65 ms 180428 KB Output is correct
64 Correct 62 ms 180172 KB Output is correct
65 Correct 64 ms 180172 KB Output is correct
66 Correct 67 ms 180172 KB Output is correct
67 Correct 63 ms 180420 KB Output is correct
68 Correct 79 ms 180176 KB Output is correct
69 Correct 19 ms 119644 KB Output is correct
70 Correct 19 ms 119644 KB Output is correct
71 Correct 19 ms 119644 KB Output is correct
72 Correct 18 ms 119640 KB Output is correct
73 Correct 19 ms 119644 KB Output is correct
74 Correct 19 ms 119640 KB Output is correct
75 Correct 19 ms 119644 KB Output is correct
76 Correct 20 ms 119644 KB Output is correct
77 Correct 21 ms 119608 KB Output is correct
78 Correct 18 ms 119644 KB Output is correct
79 Correct 18 ms 119644 KB Output is correct
80 Correct 19 ms 119644 KB Output is correct
81 Correct 20 ms 119644 KB Output is correct
82 Correct 19 ms 119644 KB Output is correct
83 Correct 19 ms 119456 KB Output is correct
84 Correct 19 ms 119536 KB Output is correct
85 Correct 19 ms 119484 KB Output is correct
86 Correct 19 ms 119636 KB Output is correct
87 Correct 18 ms 119644 KB Output is correct
88 Correct 19 ms 119548 KB Output is correct
89 Correct 18 ms 119644 KB Output is correct
90 Correct 20 ms 119644 KB Output is correct
91 Correct 19 ms 119516 KB Output is correct
92 Correct 19 ms 119644 KB Output is correct
93 Correct 19 ms 119644 KB Output is correct
94 Correct 19 ms 119644 KB Output is correct
95 Correct 19 ms 119644 KB Output is correct
96 Correct 19 ms 119644 KB Output is correct
97 Correct 19 ms 119572 KB Output is correct
98 Correct 19 ms 119644 KB Output is correct
99 Correct 19 ms 119480 KB Output is correct
100 Correct 41 ms 133340 KB Output is correct
101 Correct 45 ms 133340 KB Output is correct
102 Correct 46 ms 133340 KB Output is correct
103 Correct 39 ms 133356 KB Output is correct
104 Correct 37 ms 133336 KB Output is correct
105 Correct 50 ms 148928 KB Output is correct
106 Correct 53 ms 148940 KB Output is correct
107 Correct 47 ms 148952 KB Output is correct
108 Correct 49 ms 148944 KB Output is correct
109 Correct 47 ms 149012 KB Output is correct
110 Correct 43 ms 133336 KB Output is correct
111 Correct 42 ms 133336 KB Output is correct
112 Correct 40 ms 133288 KB Output is correct
113 Correct 39 ms 133328 KB Output is correct
114 Correct 40 ms 133336 KB Output is correct
115 Correct 71 ms 180172 KB Output is correct
116 Correct 65 ms 180176 KB Output is correct
117 Correct 65 ms 180368 KB Output is correct
118 Correct 64 ms 180172 KB Output is correct
119 Correct 65 ms 180172 KB Output is correct
120 Correct 40 ms 133332 KB Output is correct
121 Correct 39 ms 133340 KB Output is correct
122 Correct 42 ms 133316 KB Output is correct
123 Correct 43 ms 133340 KB Output is correct
124 Correct 54 ms 156876 KB Output is correct
125 Correct 50 ms 156884 KB Output is correct
126 Correct 49 ms 156888 KB Output is correct
127 Correct 49 ms 156884 KB Output is correct
128 Correct 31 ms 126940 KB Output is correct
129 Correct 27 ms 126908 KB Output is correct
130 Correct 26 ms 126936 KB Output is correct
131 Correct 18 ms 119632 KB Output is correct