답안 #970027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970027 2024-04-26T06:51:22 Z 12345678 Homework (CEOI22_homework) C++17
53 / 100
194 ms 157836 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=1e6+5;

int n, t[nx], sz[nx], mn[nx], mx[nx], cnt;
vector<int> d[nx];
string s;

int build(int l, int i)
{
    if (s[l]=='?') return l;
    if (s[l+1]=='i') t[i]=1;
    else t[i]=2;
    d[i].push_back(++cnt);
    int tmp=build(l+4, cnt);
    l=tmp+2;
    d[i].push_back(++cnt);
    tmp=build(l, cnt);
    return tmp+1; 
}

void solve(int i)
{
    if (t[i]==0) return sz[i]=mn[i]=mx[i]=1, void();
    solve(d[i][0]);
    solve(d[i][1]);
    sz[i]=sz[d[i][0]]+sz[d[i][1]];
    if (t[i]==1)
    {
        mn[i]=min(mn[d[i][0]], mn[d[i][1]]);
        mx[i]=mx[d[i][0]]+mx[d[i][1]]-1;
    }
    if (t[i]==2)
    {
        mn[i]=mn[d[i][0]]+mn[d[i][1]];
        mx[i]=max(sz[d[i][0]]+mx[d[i][1]], mx[d[i][0]]+sz[d[i][1]]);
    }
    //cout<<"debug "<<i<<' '<<mn[i]<<' '<<mx[i]<<'\n';
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>s;
    cnt=1;
    n=s.size();
    build(0, 1);
    solve(1);
    cout<<mx[1]-mn[1]+1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 31320 KB Output is correct
2 Correct 8 ms 31476 KB Output is correct
3 Correct 7 ms 31320 KB Output is correct
4 Correct 8 ms 31324 KB Output is correct
5 Correct 7 ms 31324 KB Output is correct
6 Correct 9 ms 31324 KB Output is correct
7 Correct 7 ms 31324 KB Output is correct
8 Correct 8 ms 31324 KB Output is correct
9 Correct 7 ms 31324 KB Output is correct
10 Correct 6 ms 31324 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 7 ms 31324 KB Output is correct
13 Correct 7 ms 31400 KB Output is correct
14 Correct 6 ms 31324 KB Output is correct
15 Correct 7 ms 31352 KB Output is correct
16 Correct 8 ms 31324 KB Output is correct
17 Correct 6 ms 31324 KB Output is correct
18 Correct 6 ms 31324 KB Output is correct
19 Correct 8 ms 31324 KB Output is correct
20 Correct 7 ms 31324 KB Output is correct
21 Correct 6 ms 31324 KB Output is correct
22 Correct 7 ms 31324 KB Output is correct
23 Correct 7 ms 31320 KB Output is correct
24 Correct 6 ms 31324 KB Output is correct
25 Correct 6 ms 31324 KB Output is correct
26 Correct 6 ms 31324 KB Output is correct
27 Correct 7 ms 31320 KB Output is correct
28 Correct 7 ms 31324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 31320 KB Output is correct
2 Correct 8 ms 31476 KB Output is correct
3 Correct 7 ms 31320 KB Output is correct
4 Correct 8 ms 31324 KB Output is correct
5 Correct 7 ms 31324 KB Output is correct
6 Correct 9 ms 31324 KB Output is correct
7 Correct 7 ms 31324 KB Output is correct
8 Correct 8 ms 31324 KB Output is correct
9 Correct 7 ms 31324 KB Output is correct
10 Correct 6 ms 31324 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 7 ms 31324 KB Output is correct
13 Correct 7 ms 31400 KB Output is correct
14 Correct 6 ms 31324 KB Output is correct
15 Correct 7 ms 31352 KB Output is correct
16 Correct 8 ms 31324 KB Output is correct
17 Correct 6 ms 31324 KB Output is correct
18 Correct 6 ms 31324 KB Output is correct
19 Correct 8 ms 31324 KB Output is correct
20 Correct 7 ms 31324 KB Output is correct
21 Correct 6 ms 31324 KB Output is correct
22 Correct 7 ms 31324 KB Output is correct
23 Correct 7 ms 31320 KB Output is correct
24 Correct 6 ms 31324 KB Output is correct
25 Correct 6 ms 31324 KB Output is correct
26 Correct 6 ms 31324 KB Output is correct
27 Correct 7 ms 31320 KB Output is correct
28 Correct 7 ms 31324 KB Output is correct
29 Correct 6 ms 31324 KB Output is correct
30 Correct 6 ms 31360 KB Output is correct
31 Correct 7 ms 31324 KB Output is correct
32 Correct 6 ms 31324 KB Output is correct
33 Correct 6 ms 31320 KB Output is correct
34 Correct 7 ms 31324 KB Output is correct
35 Correct 6 ms 31404 KB Output is correct
36 Correct 7 ms 31324 KB Output is correct
37 Correct 8 ms 31320 KB Output is correct
38 Correct 7 ms 31324 KB Output is correct
39 Correct 8 ms 31580 KB Output is correct
40 Correct 7 ms 31324 KB Output is correct
41 Correct 7 ms 31320 KB Output is correct
42 Correct 7 ms 31324 KB Output is correct
43 Correct 7 ms 31324 KB Output is correct
44 Correct 6 ms 31324 KB Output is correct
45 Correct 7 ms 31356 KB Output is correct
46 Correct 7 ms 31416 KB Output is correct
47 Correct 7 ms 31324 KB Output is correct
48 Correct 7 ms 31324 KB Output is correct
49 Correct 7 ms 31324 KB Output is correct
50 Correct 6 ms 31340 KB Output is correct
51 Correct 7 ms 31348 KB Output is correct
52 Correct 6 ms 31324 KB Output is correct
53 Correct 7 ms 31360 KB Output is correct
54 Correct 7 ms 31368 KB Output is correct
55 Correct 6 ms 31324 KB Output is correct
56 Correct 7 ms 31324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 194 ms 157836 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 31320 KB Output is correct
2 Correct 8 ms 31476 KB Output is correct
3 Correct 7 ms 31320 KB Output is correct
4 Correct 8 ms 31324 KB Output is correct
5 Correct 7 ms 31324 KB Output is correct
6 Correct 9 ms 31324 KB Output is correct
7 Correct 7 ms 31324 KB Output is correct
8 Correct 8 ms 31324 KB Output is correct
9 Correct 7 ms 31324 KB Output is correct
10 Correct 6 ms 31324 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 7 ms 31324 KB Output is correct
13 Correct 7 ms 31400 KB Output is correct
14 Correct 6 ms 31324 KB Output is correct
15 Correct 7 ms 31352 KB Output is correct
16 Correct 8 ms 31324 KB Output is correct
17 Correct 6 ms 31324 KB Output is correct
18 Correct 6 ms 31324 KB Output is correct
19 Correct 8 ms 31324 KB Output is correct
20 Correct 7 ms 31324 KB Output is correct
21 Correct 6 ms 31324 KB Output is correct
22 Correct 7 ms 31324 KB Output is correct
23 Correct 7 ms 31320 KB Output is correct
24 Correct 6 ms 31324 KB Output is correct
25 Correct 6 ms 31324 KB Output is correct
26 Correct 6 ms 31324 KB Output is correct
27 Correct 7 ms 31320 KB Output is correct
28 Correct 7 ms 31324 KB Output is correct
29 Correct 6 ms 31324 KB Output is correct
30 Correct 6 ms 31360 KB Output is correct
31 Correct 7 ms 31324 KB Output is correct
32 Correct 6 ms 31324 KB Output is correct
33 Correct 6 ms 31320 KB Output is correct
34 Correct 7 ms 31324 KB Output is correct
35 Correct 6 ms 31404 KB Output is correct
36 Correct 7 ms 31324 KB Output is correct
37 Correct 8 ms 31320 KB Output is correct
38 Correct 7 ms 31324 KB Output is correct
39 Correct 8 ms 31580 KB Output is correct
40 Correct 7 ms 31324 KB Output is correct
41 Correct 7 ms 31320 KB Output is correct
42 Correct 7 ms 31324 KB Output is correct
43 Correct 7 ms 31324 KB Output is correct
44 Correct 6 ms 31324 KB Output is correct
45 Correct 7 ms 31356 KB Output is correct
46 Correct 7 ms 31416 KB Output is correct
47 Correct 7 ms 31324 KB Output is correct
48 Correct 7 ms 31324 KB Output is correct
49 Correct 7 ms 31324 KB Output is correct
50 Correct 6 ms 31340 KB Output is correct
51 Correct 7 ms 31348 KB Output is correct
52 Correct 6 ms 31324 KB Output is correct
53 Correct 7 ms 31360 KB Output is correct
54 Correct 7 ms 31368 KB Output is correct
55 Correct 6 ms 31324 KB Output is correct
56 Correct 7 ms 31324 KB Output is correct
57 Correct 7 ms 31324 KB Output is correct
58 Correct 6 ms 31324 KB Output is correct
59 Correct 7 ms 31324 KB Output is correct
60 Correct 7 ms 31324 KB Output is correct
61 Correct 6 ms 31324 KB Output is correct
62 Correct 7 ms 31324 KB Output is correct
63 Correct 7 ms 31324 KB Output is correct
64 Correct 7 ms 31424 KB Output is correct
65 Correct 7 ms 31324 KB Output is correct
66 Correct 7 ms 31324 KB Output is correct
67 Correct 7 ms 31420 KB Output is correct
68 Correct 7 ms 31324 KB Output is correct
69 Correct 7 ms 31324 KB Output is correct
70 Correct 7 ms 31464 KB Output is correct
71 Correct 7 ms 31324 KB Output is correct
72 Correct 7 ms 31324 KB Output is correct
73 Correct 7 ms 31324 KB Output is correct
74 Correct 7 ms 31508 KB Output is correct
75 Correct 8 ms 31484 KB Output is correct
76 Correct 7 ms 31504 KB Output is correct
77 Correct 7 ms 31324 KB Output is correct
78 Correct 7 ms 31324 KB Output is correct
79 Correct 7 ms 31332 KB Output is correct
80 Correct 7 ms 31324 KB Output is correct
81 Correct 7 ms 31324 KB Output is correct
82 Correct 7 ms 31324 KB Output is correct
83 Correct 7 ms 31324 KB Output is correct
84 Correct 7 ms 31372 KB Output is correct
85 Correct 7 ms 31320 KB Output is correct
86 Correct 7 ms 31324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 31320 KB Output is correct
2 Correct 8 ms 31476 KB Output is correct
3 Correct 7 ms 31320 KB Output is correct
4 Correct 8 ms 31324 KB Output is correct
5 Correct 7 ms 31324 KB Output is correct
6 Correct 9 ms 31324 KB Output is correct
7 Correct 7 ms 31324 KB Output is correct
8 Correct 8 ms 31324 KB Output is correct
9 Correct 7 ms 31324 KB Output is correct
10 Correct 6 ms 31324 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 7 ms 31324 KB Output is correct
13 Correct 7 ms 31400 KB Output is correct
14 Correct 6 ms 31324 KB Output is correct
15 Correct 7 ms 31352 KB Output is correct
16 Correct 8 ms 31324 KB Output is correct
17 Correct 6 ms 31324 KB Output is correct
18 Correct 6 ms 31324 KB Output is correct
19 Correct 8 ms 31324 KB Output is correct
20 Correct 7 ms 31324 KB Output is correct
21 Correct 6 ms 31324 KB Output is correct
22 Correct 7 ms 31324 KB Output is correct
23 Correct 7 ms 31320 KB Output is correct
24 Correct 6 ms 31324 KB Output is correct
25 Correct 6 ms 31324 KB Output is correct
26 Correct 6 ms 31324 KB Output is correct
27 Correct 7 ms 31320 KB Output is correct
28 Correct 7 ms 31324 KB Output is correct
29 Correct 6 ms 31324 KB Output is correct
30 Correct 6 ms 31360 KB Output is correct
31 Correct 7 ms 31324 KB Output is correct
32 Correct 6 ms 31324 KB Output is correct
33 Correct 6 ms 31320 KB Output is correct
34 Correct 7 ms 31324 KB Output is correct
35 Correct 6 ms 31404 KB Output is correct
36 Correct 7 ms 31324 KB Output is correct
37 Correct 8 ms 31320 KB Output is correct
38 Correct 7 ms 31324 KB Output is correct
39 Correct 8 ms 31580 KB Output is correct
40 Correct 7 ms 31324 KB Output is correct
41 Correct 7 ms 31320 KB Output is correct
42 Correct 7 ms 31324 KB Output is correct
43 Correct 7 ms 31324 KB Output is correct
44 Correct 6 ms 31324 KB Output is correct
45 Correct 7 ms 31356 KB Output is correct
46 Correct 7 ms 31416 KB Output is correct
47 Correct 7 ms 31324 KB Output is correct
48 Correct 7 ms 31324 KB Output is correct
49 Correct 7 ms 31324 KB Output is correct
50 Correct 6 ms 31340 KB Output is correct
51 Correct 7 ms 31348 KB Output is correct
52 Correct 6 ms 31324 KB Output is correct
53 Correct 7 ms 31360 KB Output is correct
54 Correct 7 ms 31368 KB Output is correct
55 Correct 6 ms 31324 KB Output is correct
56 Correct 7 ms 31324 KB Output is correct
57 Runtime error 194 ms 157836 KB Execution killed with signal 6
58 Halted 0 ms 0 KB -