# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1009333 |
2024-06-27T11:35:46 Z |
Muhammet |
Wall (IOI14_wall) |
C++17 |
|
588 ms |
105172 KB |
#include <bits/stdc++.h>
#include "wall.h"
#define ll long long
#define ff first
#define ss second
#define sz(s) (int)s.size()
using namespace std;
const ll N = 8000002;
pair<int,int> st[N];
vector <int> v;
void lz(int nd){
if(nd * 2 < N){
st[nd*2].ff = min(st[nd].ss,st[nd*2].ff);
st[nd*2].ff = max(st[nd].ff,st[nd*2].ff);
st[nd*2].ss = min(st[nd].ss,st[nd*2].ss);
st[nd*2].ss = max(st[nd].ff,st[nd*2].ss);
}
if(nd * 2 + 1 < N){
st[nd*2+1].ff = min(st[nd].ss,st[nd*2+1].ff);
st[nd*2+1].ff = max(st[nd].ff,st[nd*2+1].ff);
st[nd*2+1].ss = min(st[nd].ss,st[nd*2+1].ss);
st[nd*2+1].ss = max(st[nd].ff,st[nd*2+1].ss);
}
return;
}
void upd(int nd, int l, int r, int x, int y, int h, int t){
lz(nd);
if(l > y or r < x) return;
if(l >= x and r <= y){
if(t == 1){
st[nd].ff = max(st[nd].ff,h);
st[nd].ss = max(st[nd].ss,h);
}
else {
st[nd].ff = min(st[nd].ff,h);
st[nd].ss = min(st[nd].ss,h);
}
return;
}
st[nd].ff = -1e9;
st[nd].ss = 1e9;
int md = (l + r) / 2;
upd(nd*2,l,md,x,y,h,t);
upd(nd*2+1,md+1,r,x,y,h,t);
}
void fnd(int nd, int l, int r){
lz(nd);
if(l == r){
v.push_back(st[nd].ff);
return;
}
int md = (l + r) / 2;
fnd(nd*2, l, md);
fnd(nd*2+1, md+1, r);
}
void buildWall(int n, int k, int t[], int l[], int r[], int h[], int a[]){
for(int i = 0; i < k; i++){
upd(1,0,n-1,l[i],r[i],h[i],t[i]);
}
fnd(1,0,n-1);
for(int i = 0; i < n; i++){
a[i] = v[i];
}
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
1116 KB |
Output is correct |
5 |
Correct |
4 ms |
1116 KB |
Output is correct |
6 |
Correct |
4 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
87 ms |
8136 KB |
Output is correct |
3 |
Correct |
116 ms |
4948 KB |
Output is correct |
4 |
Correct |
345 ms |
13256 KB |
Output is correct |
5 |
Correct |
241 ms |
13768 KB |
Output is correct |
6 |
Correct |
221 ms |
13768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
1116 KB |
Output is correct |
5 |
Correct |
4 ms |
1112 KB |
Output is correct |
6 |
Correct |
4 ms |
1116 KB |
Output is correct |
7 |
Correct |
0 ms |
600 KB |
Output is correct |
8 |
Correct |
111 ms |
8200 KB |
Output is correct |
9 |
Correct |
127 ms |
4944 KB |
Output is correct |
10 |
Correct |
361 ms |
13264 KB |
Output is correct |
11 |
Correct |
233 ms |
13820 KB |
Output is correct |
12 |
Correct |
235 ms |
13968 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
85 ms |
8232 KB |
Output is correct |
15 |
Correct |
21 ms |
2140 KB |
Output is correct |
16 |
Correct |
360 ms |
13560 KB |
Output is correct |
17 |
Correct |
258 ms |
13516 KB |
Output is correct |
18 |
Correct |
238 ms |
13524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
1204 KB |
Output is correct |
5 |
Correct |
4 ms |
1116 KB |
Output is correct |
6 |
Correct |
4 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
79 ms |
8268 KB |
Output is correct |
9 |
Correct |
129 ms |
5204 KB |
Output is correct |
10 |
Correct |
355 ms |
13384 KB |
Output is correct |
11 |
Correct |
219 ms |
13772 KB |
Output is correct |
12 |
Correct |
206 ms |
13912 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
77 ms |
8248 KB |
Output is correct |
15 |
Correct |
24 ms |
2140 KB |
Output is correct |
16 |
Correct |
342 ms |
13516 KB |
Output is correct |
17 |
Correct |
209 ms |
13516 KB |
Output is correct |
18 |
Correct |
214 ms |
13516 KB |
Output is correct |
19 |
Correct |
588 ms |
96776 KB |
Output is correct |
20 |
Correct |
555 ms |
102580 KB |
Output is correct |
21 |
Correct |
542 ms |
105172 KB |
Output is correct |
22 |
Correct |
529 ms |
102464 KB |
Output is correct |
23 |
Correct |
560 ms |
102580 KB |
Output is correct |
24 |
Correct |
550 ms |
102504 KB |
Output is correct |
25 |
Correct |
523 ms |
102604 KB |
Output is correct |
26 |
Correct |
519 ms |
105136 KB |
Output is correct |
27 |
Correct |
583 ms |
105136 KB |
Output is correct |
28 |
Correct |
525 ms |
102596 KB |
Output is correct |
29 |
Correct |
523 ms |
102516 KB |
Output is correct |
30 |
Correct |
524 ms |
102452 KB |
Output is correct |