답안 #1056744

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1056744 2024-08-13T10:49:12 Z amirhoseinfar1385 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 29916 KB
#include "towers.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10,lg=18,kaf=(1<<lg),inf=1e9+5;
int all[maxn];

struct segmentmin{
  pair<long long ,long long>seg[(1<<(lg+1))];
  segmentmin(){
    for(int i=2*kaf-1;i>=0;i--){
      if(i>=kaf){
        seg[i].second=i-kaf;
      }else{
        seg[i].second=seg[(i<<1)].second;
      }
    }
  }
  void ins(int i,int w){
    i+=kaf;
    seg[i].first=w;
    i>>=1;
    while(i>0){
      seg[i]=min(seg[(i<<1)],seg[(i<<1)^1]);
      i>>=1;
    }
  }
  pair<long long ,long long> pors(int i,int l,int r,int tl,int tr){
    if(l>r||l>tr||r<tl||tl>tr){
      return make_pair(inf,inf);
    }
    if(l>=tl&&r<=tr){
      return seg[i];
    }
    int m=(l+r)>>1;
    return min(pors((i<<1),l,m,tl,tr),pors((i<<1)^1,m+1,r,tl,tr));
  }
}segmn;


struct segmentmax{
  pair<long long ,long long>seg[(1<<(lg+1))];
  segmentmax(){
    for(int i=2*kaf-1;i>=0;i--){
      if(i>=kaf){
        seg[i].second=i-kaf;
      }else{
        seg[i].second=seg[(i<<1)].second;
      }
    }
  }
  void ins(int i,int w){
    i+=kaf;
    seg[i].first=w;
    i>>=1;
    while(i>0){
      seg[i]=max(seg[(i<<1)],seg[(i<<1)^1]);
      i>>=1;
    }
  }
  pair<long long ,long long> pors(int i,int l,int r,int tl,int tr){
    if(l>r||l>tr||r<tl||tl>tr){
      return make_pair(0,0);
    }
    if(l>=tl&&r<=tr){
      return seg[i];
    }
    int m=(l+r)>>1;
    return max(pors((i<<1),l,m,tl,tr),pors((i<<1)^1,m+1,r,tl,tr));
  }
}segmx;
int n;

void init(int N, std::vector<int> H) {
  n=N;
  for(int i=0;i<n;i++){
    all[i]=H[i];
    segmx.ins(i,H[i]);
    segmn.ins(i,H[i]);
  }
}

int solve(int l,int r,int d){
  if(l==r){
    return 1;
  }
  int ind=segmx.pors(1,0,kaf-1,l,r).second;
  int cl=0,cr=0,ret=0;
  if(segmn.pors(1,0,kaf-1,l,ind-1).first<=all[ind]-d){
    cl=solve(l,ind-1,d);
  }
  if(segmn.pors(1,0,kaf-1,ind+1,r).first<=all[ind]-d){
    cr=solve(ind+1,r,d);
  }
  ret=cl+cr;
  //cout<<"wtF: "<<l<<" "<<r<<" "<<d<<" "<<cl<<" "<<cr<<endl;
  ret=max(ret,1);
  return ret;
}

int max_towers(int L, int R, int D) {
  return solve(L,R,D);
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4054 ms 23032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 16984 KB Output is correct
2 Correct 4 ms 17040 KB Output is correct
3 Correct 3 ms 16984 KB Output is correct
4 Correct 4 ms 16984 KB Output is correct
5 Correct 4 ms 16984 KB Output is correct
6 Correct 3 ms 16996 KB Output is correct
7 Correct 3 ms 16984 KB Output is correct
8 Correct 3 ms 16824 KB Output is correct
9 Correct 3 ms 17008 KB Output is correct
10 Correct 4 ms 16832 KB Output is correct
11 Correct 3 ms 16984 KB Output is correct
12 Correct 2 ms 16984 KB Output is correct
13 Correct 3 ms 16984 KB Output is correct
14 Correct 4 ms 16984 KB Output is correct
15 Correct 4 ms 16984 KB Output is correct
16 Correct 4 ms 16984 KB Output is correct
17 Correct 3 ms 16984 KB Output is correct
18 Correct 3 ms 16984 KB Output is correct
19 Correct 3 ms 16984 KB Output is correct
20 Correct 4 ms 16984 KB Output is correct
21 Correct 3 ms 16984 KB Output is correct
22 Correct 3 ms 16984 KB Output is correct
23 Correct 3 ms 17240 KB Output is correct
24 Correct 4 ms 16984 KB Output is correct
25 Correct 3 ms 16984 KB Output is correct
26 Correct 3 ms 16824 KB Output is correct
27 Correct 4 ms 16984 KB Output is correct
28 Correct 3 ms 16824 KB Output is correct
29 Correct 4 ms 17008 KB Output is correct
30 Correct 3 ms 16984 KB Output is correct
31 Correct 3 ms 16984 KB Output is correct
32 Correct 4 ms 16984 KB Output is correct
33 Correct 4 ms 16984 KB Output is correct
34 Correct 3 ms 16984 KB Output is correct
35 Correct 4 ms 17240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 16984 KB Output is correct
2 Correct 4 ms 17040 KB Output is correct
3 Correct 3 ms 16984 KB Output is correct
4 Correct 4 ms 16984 KB Output is correct
5 Correct 4 ms 16984 KB Output is correct
6 Correct 3 ms 16996 KB Output is correct
7 Correct 3 ms 16984 KB Output is correct
8 Correct 3 ms 16824 KB Output is correct
9 Correct 3 ms 17008 KB Output is correct
10 Correct 4 ms 16832 KB Output is correct
11 Correct 3 ms 16984 KB Output is correct
12 Correct 2 ms 16984 KB Output is correct
13 Correct 3 ms 16984 KB Output is correct
14 Correct 4 ms 16984 KB Output is correct
15 Correct 4 ms 16984 KB Output is correct
16 Correct 4 ms 16984 KB Output is correct
17 Correct 3 ms 16984 KB Output is correct
18 Correct 3 ms 16984 KB Output is correct
19 Correct 3 ms 16984 KB Output is correct
20 Correct 4 ms 16984 KB Output is correct
21 Correct 3 ms 16984 KB Output is correct
22 Correct 3 ms 16984 KB Output is correct
23 Correct 3 ms 17240 KB Output is correct
24 Correct 4 ms 16984 KB Output is correct
25 Correct 3 ms 16984 KB Output is correct
26 Correct 3 ms 16824 KB Output is correct
27 Correct 4 ms 16984 KB Output is correct
28 Correct 3 ms 16824 KB Output is correct
29 Correct 4 ms 17008 KB Output is correct
30 Correct 3 ms 16984 KB Output is correct
31 Correct 3 ms 16984 KB Output is correct
32 Correct 4 ms 16984 KB Output is correct
33 Correct 4 ms 16984 KB Output is correct
34 Correct 3 ms 16984 KB Output is correct
35 Correct 4 ms 17240 KB Output is correct
36 Correct 24 ms 17540 KB Output is correct
37 Correct 33 ms 18012 KB Output is correct
38 Correct 30 ms 17944 KB Output is correct
39 Correct 27 ms 18008 KB Output is correct
40 Correct 23 ms 18008 KB Output is correct
41 Correct 35 ms 17796 KB Output is correct
42 Correct 21 ms 17944 KB Output is correct
43 Correct 56 ms 21528 KB Output is correct
44 Correct 30 ms 18008 KB Output is correct
45 Correct 34 ms 18008 KB Output is correct
46 Correct 19 ms 18008 KB Output is correct
47 Correct 34 ms 18000 KB Output is correct
48 Correct 25 ms 18008 KB Output is correct
49 Correct 28 ms 17940 KB Output is correct
50 Correct 31 ms 20104 KB Output is correct
51 Correct 47 ms 22324 KB Output is correct
52 Correct 46 ms 17936 KB Output is correct
53 Correct 63 ms 17856 KB Output is correct
54 Correct 62 ms 17960 KB Output is correct
55 Correct 60 ms 29916 KB Output is correct
56 Correct 63 ms 28836 KB Output is correct
57 Correct 38 ms 17944 KB Output is correct
58 Correct 40 ms 17848 KB Output is correct
59 Correct 44 ms 17820 KB Output is correct
60 Correct 47 ms 17984 KB Output is correct
61 Correct 44 ms 17940 KB Output is correct
62 Correct 43 ms 17856 KB Output is correct
63 Correct 43 ms 17980 KB Output is correct
64 Correct 41 ms 23752 KB Output is correct
65 Correct 44 ms 23032 KB Output is correct
66 Correct 39 ms 22324 KB Output is correct
67 Correct 40 ms 23284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4037 ms 18008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4035 ms 17208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 16984 KB Output is correct
2 Correct 4 ms 17040 KB Output is correct
3 Correct 3 ms 16984 KB Output is correct
4 Correct 4 ms 16984 KB Output is correct
5 Correct 4 ms 16984 KB Output is correct
6 Correct 3 ms 16996 KB Output is correct
7 Correct 3 ms 16984 KB Output is correct
8 Correct 3 ms 16824 KB Output is correct
9 Correct 3 ms 17008 KB Output is correct
10 Correct 4 ms 16832 KB Output is correct
11 Correct 3 ms 16984 KB Output is correct
12 Correct 2 ms 16984 KB Output is correct
13 Correct 3 ms 16984 KB Output is correct
14 Correct 4 ms 16984 KB Output is correct
15 Correct 4 ms 16984 KB Output is correct
16 Correct 4 ms 16984 KB Output is correct
17 Correct 3 ms 16984 KB Output is correct
18 Correct 3 ms 16984 KB Output is correct
19 Correct 3 ms 16984 KB Output is correct
20 Correct 4 ms 16984 KB Output is correct
21 Correct 3 ms 16984 KB Output is correct
22 Correct 3 ms 16984 KB Output is correct
23 Correct 3 ms 17240 KB Output is correct
24 Correct 4 ms 16984 KB Output is correct
25 Correct 3 ms 16984 KB Output is correct
26 Correct 3 ms 16824 KB Output is correct
27 Correct 4 ms 16984 KB Output is correct
28 Correct 3 ms 16824 KB Output is correct
29 Correct 4 ms 17008 KB Output is correct
30 Correct 3 ms 16984 KB Output is correct
31 Correct 3 ms 16984 KB Output is correct
32 Correct 4 ms 16984 KB Output is correct
33 Correct 4 ms 16984 KB Output is correct
34 Correct 3 ms 16984 KB Output is correct
35 Correct 4 ms 17240 KB Output is correct
36 Correct 24 ms 17540 KB Output is correct
37 Correct 33 ms 18012 KB Output is correct
38 Correct 30 ms 17944 KB Output is correct
39 Correct 27 ms 18008 KB Output is correct
40 Correct 23 ms 18008 KB Output is correct
41 Correct 35 ms 17796 KB Output is correct
42 Correct 21 ms 17944 KB Output is correct
43 Correct 56 ms 21528 KB Output is correct
44 Correct 30 ms 18008 KB Output is correct
45 Correct 34 ms 18008 KB Output is correct
46 Correct 19 ms 18008 KB Output is correct
47 Correct 34 ms 18000 KB Output is correct
48 Correct 25 ms 18008 KB Output is correct
49 Correct 28 ms 17940 KB Output is correct
50 Correct 31 ms 20104 KB Output is correct
51 Correct 47 ms 22324 KB Output is correct
52 Correct 46 ms 17936 KB Output is correct
53 Correct 63 ms 17856 KB Output is correct
54 Correct 62 ms 17960 KB Output is correct
55 Correct 60 ms 29916 KB Output is correct
56 Correct 63 ms 28836 KB Output is correct
57 Correct 38 ms 17944 KB Output is correct
58 Correct 40 ms 17848 KB Output is correct
59 Correct 44 ms 17820 KB Output is correct
60 Correct 47 ms 17984 KB Output is correct
61 Correct 44 ms 17940 KB Output is correct
62 Correct 43 ms 17856 KB Output is correct
63 Correct 43 ms 17980 KB Output is correct
64 Correct 41 ms 23752 KB Output is correct
65 Correct 44 ms 23032 KB Output is correct
66 Correct 39 ms 22324 KB Output is correct
67 Correct 40 ms 23284 KB Output is correct
68 Execution timed out 4037 ms 18008 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4054 ms 23032 KB Time limit exceeded
2 Halted 0 ms 0 KB -