답안 #1053177

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053177 2024-08-11T09:23:53 Z hirayuu_oj 송신탑 (IOI22_towers) C++17
56 / 100
779 ms 11464 KB
#include "towers.h"

#include <vector>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define rng(i,l,r) for(int i=(l); i<(r); i++)
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll INF=1LL<<60;
struct SegTree {
    vector<int> tree;
    int size;
    SegTree(int sz) {
        tree.resize(sz*2,0);
        size=sz;
    }
    void resize(int sz) {
        tree.resize(sz*2,0);
        size=sz;
    }
    void set(int p,int v) {
        p+=size;
        tree[p]=v;
        p/=2;
        while(p>=1) {
            tree[p]=max(tree[p*2],tree[p*2+1]);
            p/=2;
        }
    }
    int prod(int l,int r) {
        int ret=0;
        l+=size;
        r+=size;
        while(l<r) {
            if(l&1) {
                ret=max(ret,tree[l]);
                l++;
            }
            if(r&1) {
                r--;
                ret=max(ret,tree[r]);
            }
            l/=2;
            r/=2;
        }
        return ret;
    }
};
bool flg=false;
vector<int> h;
int n;
SegTree seg(0);
vector<int> lf;
vector<int> hr;
vector<int> ri;
vector<vector<int>> dbl;
void init(int N, std::vector<int> H) {
    h=H;
    n=N;
    seg.resize(N);
    rep(i,N) {
        seg.set(i,H[i]);
    }
}
void init_by_d(int d) {
    lf.resize(n+1,n);
    hr.resize(n+1,n);
    ri.resize(n+1,n);
    dbl.resize(20,vector<int>(n+1,0));
    rep(i,n) {
        int ok,ng;
        ok=-1;
        ng=i;
        while(abs(ok-ng)>1) {
            int mid=(ok+ng)/2;
            if(seg.prod(mid,i)>=h[i]+d)ok=mid;
            else ng=mid;
        }
        int l=ok;
        ok=n;
        ng=i;
        while(abs(ok-ng)>1) {
            int mid=(ok+ng)/2;
            if(seg.prod(i,mid+1)>=h[i]+d)ok=mid;
            else ng=mid;
        }
        if(l!=-1) {
            lf[l]=min(lf[l],ok);
            hr[l]=min(hr[l],i);
        }
        ri[i]=ok;
    }
    rrep(i,n) {
        lf[i]=min(lf[i],lf[i+1]);
        ri[i]=min(ri[i],ri[i+1]);
        hr[i]=min(hr[i],hr[i+1]);
    }
    dbl[0]=lf;
    rng(i,1,20) {
        rep(j,n+1) {
            dbl[i][j]=dbl[i-1][dbl[i-1][j]];
        }
    }
}

int max_towers(int L, int R, int D) {
    if(!flg) {
        flg=true;
        init_by_d(D);
    }
    if(R<ri[L])return 1;
    int pos=ri[L];
    int ans=1;
    rrep(i,20) {
        if(dbl[i][pos]<=R) {
            ans+=1<<i;
            pos=dbl[i][pos];
        }
    }
    if(hr[pos]<=R)ans++;
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 320 ms 6764 KB 31st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
5 Correct 2 ms 644 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 2 ms 600 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 2 ms 432 KB Output is correct
14 Correct 2 ms 600 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 2 ms 600 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 2 ms 600 KB Output is correct
19 Correct 2 ms 644 KB Output is correct
20 Correct 2 ms 600 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 2 ms 600 KB Output is correct
23 Correct 2 ms 608 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 1 ms 356 KB Output is correct
26 Correct 3 ms 660 KB Output is correct
27 Correct 2 ms 612 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 2 ms 600 KB Output is correct
32 Correct 2 ms 608 KB Output is correct
33 Correct 2 ms 612 KB Output is correct
34 Correct 2 ms 612 KB Output is correct
35 Correct 2 ms 608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
5 Correct 2 ms 644 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 2 ms 600 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 2 ms 432 KB Output is correct
14 Correct 2 ms 600 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 2 ms 600 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 2 ms 600 KB Output is correct
19 Correct 2 ms 644 KB Output is correct
20 Correct 2 ms 600 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 2 ms 600 KB Output is correct
23 Correct 2 ms 608 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 1 ms 356 KB Output is correct
26 Correct 3 ms 660 KB Output is correct
27 Correct 2 ms 612 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 2 ms 600 KB Output is correct
32 Correct 2 ms 608 KB Output is correct
33 Correct 2 ms 612 KB Output is correct
34 Correct 2 ms 612 KB Output is correct
35 Correct 2 ms 608 KB Output is correct
36 Correct 79 ms 7352 KB Output is correct
37 Correct 181 ms 11388 KB Output is correct
38 Correct 154 ms 11216 KB Output is correct
39 Correct 185 ms 11376 KB Output is correct
40 Correct 159 ms 11388 KB Output is correct
41 Correct 206 ms 11216 KB Output is correct
42 Correct 133 ms 11388 KB Output is correct
43 Correct 184 ms 11376 KB Output is correct
44 Correct 209 ms 11216 KB Output is correct
45 Correct 208 ms 11208 KB Output is correct
46 Correct 195 ms 11384 KB Output is correct
47 Correct 120 ms 11216 KB Output is correct
48 Correct 140 ms 11216 KB Output is correct
49 Correct 119 ms 11376 KB Output is correct
50 Correct 157 ms 11216 KB Output is correct
51 Correct 152 ms 11376 KB Output is correct
52 Correct 126 ms 11216 KB Output is correct
53 Correct 121 ms 11216 KB Output is correct
54 Correct 125 ms 11216 KB Output is correct
55 Correct 155 ms 11216 KB Output is correct
56 Correct 149 ms 11216 KB Output is correct
57 Correct 177 ms 11008 KB Output is correct
58 Correct 162 ms 11216 KB Output is correct
59 Correct 154 ms 11216 KB Output is correct
60 Correct 129 ms 11216 KB Output is correct
61 Correct 158 ms 11380 KB Output is correct
62 Correct 155 ms 11196 KB Output is correct
63 Correct 141 ms 11216 KB Output is correct
64 Correct 201 ms 11464 KB Output is correct
65 Correct 200 ms 11216 KB Output is correct
66 Correct 187 ms 11216 KB Output is correct
67 Correct 192 ms 11380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 582 ms 11220 KB Output is correct
2 Correct 677 ms 11216 KB Output is correct
3 Correct 633 ms 11216 KB Output is correct
4 Correct 680 ms 11216 KB Output is correct
5 Correct 678 ms 11464 KB Output is correct
6 Correct 693 ms 11216 KB Output is correct
7 Correct 624 ms 11216 KB Output is correct
8 Correct 678 ms 11216 KB Output is correct
9 Correct 703 ms 11216 KB Output is correct
10 Correct 715 ms 11216 KB Output is correct
11 Correct 658 ms 11192 KB Output is correct
12 Correct 693 ms 11216 KB Output is correct
13 Correct 664 ms 11388 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 2 ms 652 KB Output is correct
16 Correct 2 ms 600 KB Output is correct
17 Correct 120 ms 11296 KB Output is correct
18 Correct 120 ms 11216 KB Output is correct
19 Correct 119 ms 11216 KB Output is correct
20 Correct 156 ms 11384 KB Output is correct
21 Correct 146 ms 11216 KB Output is correct
22 Correct 120 ms 11380 KB Output is correct
23 Correct 120 ms 11216 KB Output is correct
24 Correct 120 ms 11376 KB Output is correct
25 Correct 154 ms 11384 KB Output is correct
26 Correct 152 ms 11216 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 2 ms 652 KB Output is correct
29 Correct 1 ms 600 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 2 ms 600 KB Output is correct
32 Correct 2 ms 600 KB Output is correct
33 Correct 2 ms 600 KB Output is correct
34 Correct 2 ms 596 KB Output is correct
35 Correct 2 ms 600 KB Output is correct
36 Correct 2 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 170 ms 3044 KB 2nd lines differ - on the 1st token, expected: '7063', found: '7197'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
5 Correct 2 ms 644 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 2 ms 600 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 2 ms 432 KB Output is correct
14 Correct 2 ms 600 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 2 ms 600 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 2 ms 600 KB Output is correct
19 Correct 2 ms 644 KB Output is correct
20 Correct 2 ms 600 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 2 ms 600 KB Output is correct
23 Correct 2 ms 608 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 1 ms 356 KB Output is correct
26 Correct 3 ms 660 KB Output is correct
27 Correct 2 ms 612 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 2 ms 600 KB Output is correct
32 Correct 2 ms 608 KB Output is correct
33 Correct 2 ms 612 KB Output is correct
34 Correct 2 ms 612 KB Output is correct
35 Correct 2 ms 608 KB Output is correct
36 Correct 79 ms 7352 KB Output is correct
37 Correct 181 ms 11388 KB Output is correct
38 Correct 154 ms 11216 KB Output is correct
39 Correct 185 ms 11376 KB Output is correct
40 Correct 159 ms 11388 KB Output is correct
41 Correct 206 ms 11216 KB Output is correct
42 Correct 133 ms 11388 KB Output is correct
43 Correct 184 ms 11376 KB Output is correct
44 Correct 209 ms 11216 KB Output is correct
45 Correct 208 ms 11208 KB Output is correct
46 Correct 195 ms 11384 KB Output is correct
47 Correct 120 ms 11216 KB Output is correct
48 Correct 140 ms 11216 KB Output is correct
49 Correct 119 ms 11376 KB Output is correct
50 Correct 157 ms 11216 KB Output is correct
51 Correct 152 ms 11376 KB Output is correct
52 Correct 126 ms 11216 KB Output is correct
53 Correct 121 ms 11216 KB Output is correct
54 Correct 125 ms 11216 KB Output is correct
55 Correct 155 ms 11216 KB Output is correct
56 Correct 149 ms 11216 KB Output is correct
57 Correct 177 ms 11008 KB Output is correct
58 Correct 162 ms 11216 KB Output is correct
59 Correct 154 ms 11216 KB Output is correct
60 Correct 129 ms 11216 KB Output is correct
61 Correct 158 ms 11380 KB Output is correct
62 Correct 155 ms 11196 KB Output is correct
63 Correct 141 ms 11216 KB Output is correct
64 Correct 201 ms 11464 KB Output is correct
65 Correct 200 ms 11216 KB Output is correct
66 Correct 187 ms 11216 KB Output is correct
67 Correct 192 ms 11380 KB Output is correct
68 Correct 582 ms 11220 KB Output is correct
69 Correct 677 ms 11216 KB Output is correct
70 Correct 633 ms 11216 KB Output is correct
71 Correct 680 ms 11216 KB Output is correct
72 Correct 678 ms 11464 KB Output is correct
73 Correct 693 ms 11216 KB Output is correct
74 Correct 624 ms 11216 KB Output is correct
75 Correct 678 ms 11216 KB Output is correct
76 Correct 703 ms 11216 KB Output is correct
77 Correct 715 ms 11216 KB Output is correct
78 Correct 658 ms 11192 KB Output is correct
79 Correct 693 ms 11216 KB Output is correct
80 Correct 664 ms 11388 KB Output is correct
81 Correct 0 ms 344 KB Output is correct
82 Correct 2 ms 652 KB Output is correct
83 Correct 2 ms 600 KB Output is correct
84 Correct 120 ms 11296 KB Output is correct
85 Correct 120 ms 11216 KB Output is correct
86 Correct 119 ms 11216 KB Output is correct
87 Correct 156 ms 11384 KB Output is correct
88 Correct 146 ms 11216 KB Output is correct
89 Correct 120 ms 11380 KB Output is correct
90 Correct 120 ms 11216 KB Output is correct
91 Correct 120 ms 11376 KB Output is correct
92 Correct 154 ms 11384 KB Output is correct
93 Correct 152 ms 11216 KB Output is correct
94 Correct 2 ms 600 KB Output is correct
95 Correct 2 ms 652 KB Output is correct
96 Correct 1 ms 600 KB Output is correct
97 Correct 2 ms 600 KB Output is correct
98 Correct 2 ms 600 KB Output is correct
99 Correct 2 ms 600 KB Output is correct
100 Correct 2 ms 600 KB Output is correct
101 Correct 2 ms 596 KB Output is correct
102 Correct 2 ms 600 KB Output is correct
103 Correct 2 ms 600 KB Output is correct
104 Correct 563 ms 10148 KB Output is correct
105 Correct 779 ms 11216 KB Output is correct
106 Correct 735 ms 11216 KB Output is correct
107 Correct 701 ms 11216 KB Output is correct
108 Correct 722 ms 11384 KB Output is correct
109 Correct 762 ms 11192 KB Output is correct
110 Correct 711 ms 11216 KB Output is correct
111 Correct 743 ms 11216 KB Output is correct
112 Correct 720 ms 11216 KB Output is correct
113 Correct 729 ms 11216 KB Output is correct
114 Correct 721 ms 11216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 320 ms 6764 KB 31st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -