답안 #626100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
626100 2022-08-11T08:24:16 Z errorgorn 송신탑 (IOI22_towers) C++17
56 / 100
1475 ms 79852 KB
#include "towers.h"
 
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ii pair<int,int>
#define fi first
#define se second
 
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
 
#define rep(x,s,e) for (int x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e))?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
 
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
 
struct dat{
	int mn,mx;
	int a,b;
 
	dat(){};
 
	dat (int i){
		mn=mx=i;
		a=b=0;
	}
};
 
dat merge(dat a,dat b){
	dat res;
	res.mn=min(a.mn,b.mn);
	res.mx=max(a.mx,b.mx);
	res.a=max({a.a,b.a,a.mx-b.mn});
	res.b=max({a.b,b.b,b.mx-a.mn});
	return res;
}
 
struct node{
	int s,e,m;
	dat val;
	node *l,*r;
 
	node (int _s,int _e){
		s=_s,e=_e,m=s+e>>1;
 
		if (s!=e){
			l=new node(s,m);
			r=new node(m+1,e);
		}
	}
 
	void update(int i,int k){
		if (s==e) val=dat(k);
		else{
			if (i<=m) l->update(i,k);
			else r->update(i,k);
 
			val=merge(l->val,r->val);
		}
	}
 
	dat query(int i,int j){
		if (s==i && e==j) return val;
		else if (j<=m) return l->query(i,j);
		else if (m<i) return r->query(i,j);
		else return merge(l->query(i,m),r->query(m+1,j));
	}
} *root=new node(0,100005);
 
int n;
int arr[100005];
 
void init(signed N, vector<signed> H) {
	n=N;
	rep(x,0,n) arr[x+1]=H[x];
 
	rep(x,1,n+1) root->update(x,arr[x]);
}
 
bool proc=false;
ii tkd[200005][20]; //(nxt,score)
 
signed max_towers(signed l, signed r, signed d) {
	if (l==r) return 1;
	l++,r++; //0-based indexing is cringe
 
	if (!proc){
		memset(tkd,-1,sizeof(tkd));
 
		int r=n+1;
		rep(x,n+1,1){
			while (x<r && root->query(x,r-1).a>=d) r--;
			if (r!=n+1) tkd[x*2][0]={2*r+1,1};
		}
 
		r=n+1;
		rep(x,n+1,1){
			while (x<r && root->query(x,r-1).b>=d) r--;
			if (r!=n+1) tkd[x*2+1][0]={2*r,0};
		}
 
		rep(layer,0,19){
			rep(x,0,200005) if (tkd[x][layer].fi!=-1){
				int nxt=tkd[x][layer].fi;
				if (tkd[nxt][layer].fi==-1) continue;
 
				tkd[x][layer+1]={tkd[nxt][layer].fi,tkd[x][layer].se+tkd[nxt][layer].se};
			}
		}
 
		proc=true;
	}
 
	int curr=l*2+1;
	int ans=1;
 
	rep(x,20,0){
		if (tkd[curr][x].fi!=-1 && tkd[curr][x].fi/2<=r){
			ans+=tkd[curr][x].se;
			curr=tkd[curr][x].fi;
		}
	}
 
	return ans;
}

Compilation message

towers.cpp: In constructor 'node::node(long long int, long long int)':
towers.cpp:51:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   51 |   s=_s,e=_e,m=s+e>>1;
      |               ~^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 650 ms 79276 KB 31st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 78572 KB Output is correct
2 Correct 63 ms 78592 KB Output is correct
3 Correct 67 ms 78592 KB Output is correct
4 Correct 67 ms 78596 KB Output is correct
5 Correct 65 ms 78592 KB Output is correct
6 Correct 64 ms 78536 KB Output is correct
7 Correct 81 ms 78592 KB Output is correct
8 Correct 82 ms 78476 KB Output is correct
9 Correct 63 ms 78600 KB Output is correct
10 Correct 65 ms 78544 KB Output is correct
11 Correct 64 ms 78576 KB Output is correct
12 Correct 61 ms 78560 KB Output is correct
13 Correct 74 ms 78616 KB Output is correct
14 Correct 73 ms 78600 KB Output is correct
15 Correct 62 ms 78656 KB Output is correct
16 Correct 64 ms 78596 KB Output is correct
17 Correct 64 ms 78572 KB Output is correct
18 Correct 81 ms 78596 KB Output is correct
19 Correct 74 ms 78604 KB Output is correct
20 Correct 61 ms 78588 KB Output is correct
21 Correct 70 ms 78596 KB Output is correct
22 Correct 70 ms 78588 KB Output is correct
23 Correct 66 ms 78560 KB Output is correct
24 Correct 70 ms 78592 KB Output is correct
25 Correct 75 ms 78524 KB Output is correct
26 Correct 63 ms 78600 KB Output is correct
27 Correct 64 ms 78596 KB Output is correct
28 Correct 65 ms 78592 KB Output is correct
29 Correct 77 ms 78592 KB Output is correct
30 Correct 75 ms 78476 KB Output is correct
31 Correct 66 ms 78596 KB Output is correct
32 Correct 67 ms 78540 KB Output is correct
33 Correct 67 ms 78596 KB Output is correct
34 Correct 65 ms 78484 KB Output is correct
35 Correct 82 ms 78596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 78572 KB Output is correct
2 Correct 63 ms 78592 KB Output is correct
3 Correct 67 ms 78592 KB Output is correct
4 Correct 67 ms 78596 KB Output is correct
5 Correct 65 ms 78592 KB Output is correct
6 Correct 64 ms 78536 KB Output is correct
7 Correct 81 ms 78592 KB Output is correct
8 Correct 82 ms 78476 KB Output is correct
9 Correct 63 ms 78600 KB Output is correct
10 Correct 65 ms 78544 KB Output is correct
11 Correct 64 ms 78576 KB Output is correct
12 Correct 61 ms 78560 KB Output is correct
13 Correct 74 ms 78616 KB Output is correct
14 Correct 73 ms 78600 KB Output is correct
15 Correct 62 ms 78656 KB Output is correct
16 Correct 64 ms 78596 KB Output is correct
17 Correct 64 ms 78572 KB Output is correct
18 Correct 81 ms 78596 KB Output is correct
19 Correct 74 ms 78604 KB Output is correct
20 Correct 61 ms 78588 KB Output is correct
21 Correct 70 ms 78596 KB Output is correct
22 Correct 70 ms 78588 KB Output is correct
23 Correct 66 ms 78560 KB Output is correct
24 Correct 70 ms 78592 KB Output is correct
25 Correct 75 ms 78524 KB Output is correct
26 Correct 63 ms 78600 KB Output is correct
27 Correct 64 ms 78596 KB Output is correct
28 Correct 65 ms 78592 KB Output is correct
29 Correct 77 ms 78592 KB Output is correct
30 Correct 75 ms 78476 KB Output is correct
31 Correct 66 ms 78596 KB Output is correct
32 Correct 67 ms 78540 KB Output is correct
33 Correct 67 ms 78596 KB Output is correct
34 Correct 65 ms 78484 KB Output is correct
35 Correct 82 ms 78596 KB Output is correct
36 Correct 136 ms 79324 KB Output is correct
37 Correct 173 ms 79724 KB Output is correct
38 Correct 183 ms 79728 KB Output is correct
39 Correct 159 ms 79744 KB Output is correct
40 Correct 163 ms 79688 KB Output is correct
41 Correct 173 ms 79748 KB Output is correct
42 Correct 179 ms 79748 KB Output is correct
43 Correct 192 ms 79752 KB Output is correct
44 Correct 193 ms 79752 KB Output is correct
45 Correct 198 ms 79724 KB Output is correct
46 Correct 222 ms 79752 KB Output is correct
47 Correct 191 ms 79752 KB Output is correct
48 Correct 190 ms 79792 KB Output is correct
49 Correct 211 ms 79748 KB Output is correct
50 Correct 149 ms 79748 KB Output is correct
51 Correct 176 ms 79752 KB Output is correct
52 Correct 206 ms 79712 KB Output is correct
53 Correct 163 ms 79748 KB Output is correct
54 Correct 159 ms 79748 KB Output is correct
55 Correct 191 ms 79724 KB Output is correct
56 Correct 152 ms 79736 KB Output is correct
57 Correct 163 ms 79708 KB Output is correct
58 Correct 164 ms 79724 KB Output is correct
59 Correct 160 ms 79852 KB Output is correct
60 Correct 172 ms 79736 KB Output is correct
61 Correct 159 ms 79748 KB Output is correct
62 Correct 158 ms 79720 KB Output is correct
63 Correct 160 ms 79748 KB Output is correct
64 Correct 199 ms 79744 KB Output is correct
65 Correct 168 ms 79720 KB Output is correct
66 Correct 188 ms 79804 KB Output is correct
67 Correct 167 ms 79748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 852 ms 79740 KB Output is correct
2 Correct 1246 ms 79744 KB Output is correct
3 Correct 1381 ms 79744 KB Output is correct
4 Correct 1127 ms 79748 KB Output is correct
5 Correct 1306 ms 79748 KB Output is correct
6 Correct 1277 ms 79744 KB Output is correct
7 Correct 1161 ms 79752 KB Output is correct
8 Correct 1010 ms 79644 KB Output is correct
9 Correct 1167 ms 79748 KB Output is correct
10 Correct 1081 ms 79840 KB Output is correct
11 Correct 1033 ms 79684 KB Output is correct
12 Correct 1087 ms 79748 KB Output is correct
13 Correct 804 ms 79748 KB Output is correct
14 Correct 74 ms 78576 KB Output is correct
15 Correct 65 ms 78596 KB Output is correct
16 Correct 70 ms 78512 KB Output is correct
17 Correct 164 ms 79688 KB Output is correct
18 Correct 171 ms 79748 KB Output is correct
19 Correct 171 ms 79716 KB Output is correct
20 Correct 156 ms 79680 KB Output is correct
21 Correct 175 ms 79748 KB Output is correct
22 Correct 172 ms 79732 KB Output is correct
23 Correct 185 ms 79724 KB Output is correct
24 Correct 161 ms 79820 KB Output is correct
25 Correct 165 ms 79748 KB Output is correct
26 Correct 186 ms 79692 KB Output is correct
27 Correct 63 ms 78584 KB Output is correct
28 Correct 67 ms 78648 KB Output is correct
29 Correct 66 ms 78520 KB Output is correct
30 Correct 65 ms 78596 KB Output is correct
31 Correct 88 ms 78600 KB Output is correct
32 Correct 86 ms 78592 KB Output is correct
33 Correct 78 ms 78592 KB Output is correct
34 Correct 74 ms 78536 KB Output is correct
35 Correct 65 ms 78664 KB Output is correct
36 Correct 63 ms 78532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 420 ms 79028 KB 2nd lines differ - on the 1st token, expected: '7063', found: '7197'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 78572 KB Output is correct
2 Correct 63 ms 78592 KB Output is correct
3 Correct 67 ms 78592 KB Output is correct
4 Correct 67 ms 78596 KB Output is correct
5 Correct 65 ms 78592 KB Output is correct
6 Correct 64 ms 78536 KB Output is correct
7 Correct 81 ms 78592 KB Output is correct
8 Correct 82 ms 78476 KB Output is correct
9 Correct 63 ms 78600 KB Output is correct
10 Correct 65 ms 78544 KB Output is correct
11 Correct 64 ms 78576 KB Output is correct
12 Correct 61 ms 78560 KB Output is correct
13 Correct 74 ms 78616 KB Output is correct
14 Correct 73 ms 78600 KB Output is correct
15 Correct 62 ms 78656 KB Output is correct
16 Correct 64 ms 78596 KB Output is correct
17 Correct 64 ms 78572 KB Output is correct
18 Correct 81 ms 78596 KB Output is correct
19 Correct 74 ms 78604 KB Output is correct
20 Correct 61 ms 78588 KB Output is correct
21 Correct 70 ms 78596 KB Output is correct
22 Correct 70 ms 78588 KB Output is correct
23 Correct 66 ms 78560 KB Output is correct
24 Correct 70 ms 78592 KB Output is correct
25 Correct 75 ms 78524 KB Output is correct
26 Correct 63 ms 78600 KB Output is correct
27 Correct 64 ms 78596 KB Output is correct
28 Correct 65 ms 78592 KB Output is correct
29 Correct 77 ms 78592 KB Output is correct
30 Correct 75 ms 78476 KB Output is correct
31 Correct 66 ms 78596 KB Output is correct
32 Correct 67 ms 78540 KB Output is correct
33 Correct 67 ms 78596 KB Output is correct
34 Correct 65 ms 78484 KB Output is correct
35 Correct 82 ms 78596 KB Output is correct
36 Correct 136 ms 79324 KB Output is correct
37 Correct 173 ms 79724 KB Output is correct
38 Correct 183 ms 79728 KB Output is correct
39 Correct 159 ms 79744 KB Output is correct
40 Correct 163 ms 79688 KB Output is correct
41 Correct 173 ms 79748 KB Output is correct
42 Correct 179 ms 79748 KB Output is correct
43 Correct 192 ms 79752 KB Output is correct
44 Correct 193 ms 79752 KB Output is correct
45 Correct 198 ms 79724 KB Output is correct
46 Correct 222 ms 79752 KB Output is correct
47 Correct 191 ms 79752 KB Output is correct
48 Correct 190 ms 79792 KB Output is correct
49 Correct 211 ms 79748 KB Output is correct
50 Correct 149 ms 79748 KB Output is correct
51 Correct 176 ms 79752 KB Output is correct
52 Correct 206 ms 79712 KB Output is correct
53 Correct 163 ms 79748 KB Output is correct
54 Correct 159 ms 79748 KB Output is correct
55 Correct 191 ms 79724 KB Output is correct
56 Correct 152 ms 79736 KB Output is correct
57 Correct 163 ms 79708 KB Output is correct
58 Correct 164 ms 79724 KB Output is correct
59 Correct 160 ms 79852 KB Output is correct
60 Correct 172 ms 79736 KB Output is correct
61 Correct 159 ms 79748 KB Output is correct
62 Correct 158 ms 79720 KB Output is correct
63 Correct 160 ms 79748 KB Output is correct
64 Correct 199 ms 79744 KB Output is correct
65 Correct 168 ms 79720 KB Output is correct
66 Correct 188 ms 79804 KB Output is correct
67 Correct 167 ms 79748 KB Output is correct
68 Correct 852 ms 79740 KB Output is correct
69 Correct 1246 ms 79744 KB Output is correct
70 Correct 1381 ms 79744 KB Output is correct
71 Correct 1127 ms 79748 KB Output is correct
72 Correct 1306 ms 79748 KB Output is correct
73 Correct 1277 ms 79744 KB Output is correct
74 Correct 1161 ms 79752 KB Output is correct
75 Correct 1010 ms 79644 KB Output is correct
76 Correct 1167 ms 79748 KB Output is correct
77 Correct 1081 ms 79840 KB Output is correct
78 Correct 1033 ms 79684 KB Output is correct
79 Correct 1087 ms 79748 KB Output is correct
80 Correct 804 ms 79748 KB Output is correct
81 Correct 74 ms 78576 KB Output is correct
82 Correct 65 ms 78596 KB Output is correct
83 Correct 70 ms 78512 KB Output is correct
84 Correct 164 ms 79688 KB Output is correct
85 Correct 171 ms 79748 KB Output is correct
86 Correct 171 ms 79716 KB Output is correct
87 Correct 156 ms 79680 KB Output is correct
88 Correct 175 ms 79748 KB Output is correct
89 Correct 172 ms 79732 KB Output is correct
90 Correct 185 ms 79724 KB Output is correct
91 Correct 161 ms 79820 KB Output is correct
92 Correct 165 ms 79748 KB Output is correct
93 Correct 186 ms 79692 KB Output is correct
94 Correct 63 ms 78584 KB Output is correct
95 Correct 67 ms 78648 KB Output is correct
96 Correct 66 ms 78520 KB Output is correct
97 Correct 65 ms 78596 KB Output is correct
98 Correct 88 ms 78600 KB Output is correct
99 Correct 86 ms 78592 KB Output is correct
100 Correct 78 ms 78592 KB Output is correct
101 Correct 74 ms 78536 KB Output is correct
102 Correct 65 ms 78664 KB Output is correct
103 Correct 63 ms 78532 KB Output is correct
104 Correct 1181 ms 79628 KB Output is correct
105 Correct 1109 ms 79752 KB Output is correct
106 Correct 1027 ms 79764 KB Output is correct
107 Correct 1239 ms 79684 KB Output is correct
108 Correct 1277 ms 79724 KB Output is correct
109 Correct 1475 ms 79748 KB Output is correct
110 Correct 1313 ms 79708 KB Output is correct
111 Correct 793 ms 79752 KB Output is correct
112 Correct 1028 ms 79712 KB Output is correct
113 Correct 1010 ms 79720 KB Output is correct
114 Correct 1201 ms 79708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 650 ms 79276 KB 31st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -