# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
289335 |
2020-09-02T14:49:20 Z |
BeanZ |
벽 (IOI14_wall) |
C++14 |
|
1048 ms |
100128 KB |
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;
#define ll int
#define endl '\n'
const int N = 2e6 + 5;
ll stmin[N * 4], stmax[N * 4];
ll lazymin[N * 4], lazymax[N * 4];
ll res[N];
void down(ll k){
stmax[k << 1] = max(stmax[k << 1], lazymax[k]);
stmax[k << 1] = min(stmax[k << 1], lazymin[k]);
stmin[k << 1] = min(stmin[k << 1], lazymin[k]);
stmin[k << 1] = max(stmin[k << 1], lazymax[k]);
stmax[k << 1 | 1] = max(stmax[k << 1 | 1], lazymax[k]);
stmax[k << 1 | 1] = min(stmax[k << 1 | 1], lazymin[k]);
stmin[k << 1 | 1] = min(stmin[k << 1 | 1], lazymin[k]);
stmin[k << 1 | 1] = max(stmin[k << 1 | 1], lazymax[k]);
lazymax[k << 1 | 1] = max(lazymax[k << 1 | 1], lazymax[k]);
lazymin[k << 1 | 1] = min(lazymin[k << 1 | 1], lazymin[k]);
lazymin[k << 1 | 1] = max(lazymin[k << 1 | 1], lazymax[k]);
lazymax[k << 1 | 1] = min(lazymax[k << 1 | 1], lazymin[k]);
lazymax[k << 1] = max(lazymax[k << 1], lazymax[k]);
lazymin[k << 1] = min(lazymin[k << 1], lazymin[k]);
lazymin[k << 1] = max(lazymin[k << 1], lazymax[k]);
lazymax[k << 1] = min(lazymax[k << 1], lazymin[k]);
lazymax[k] = -1e9;
lazymin[k] = 1e9;
}
void upd(ll type, ll k, ll l, ll r, ll x, ll y, ll h){
if (x > r || y < l) return;
if (l != r) down(k);
if (x <= l && y >= r){
if (type == 1){
stmin[k] = max(stmin[k], h);
lazymin[k] = max(lazymin[k], h);
lazymax[k] = max(lazymax[k], h);
stmax[k] = max(stmax[k], h);
} else {
stmax[k] = min(stmax[k], h);
stmin[k] = min(stmin[k], h);
lazymax[k] = min(lazymax[k], h);
lazymin[k] = min(lazymin[k], h);
}
return;
}
ll mid = (l + r) >> 1;
upd(type, k << 1, l, mid, x, y, h);
upd(type, k << 1 | 1, mid + 1, r, x, y, h);
}
void get(ll k, ll l, ll r){
if (l != r) down(k);
if (l == r){
res[l] = stmax[k];
return;
}
ll mid = (l + r) >> 1;
get(k << 1, l, mid);
get(k << 1 | 1, mid + 1, r);
}
void build(ll k, ll l, ll r){
lazymin[k] = 1e9;
lazymax[k] = -1e9;
if (l == r) return;
ll mid = (l + r) >> 1;
build(k << 1, l, mid);
build(k << 1 | 1, mid + 1, r);
}
void buildWall(ll n, ll k, ll op[], ll left[], ll right[], ll height[], ll finalHeight[]){
build(1, 1, n);
for (int i = 1; i <= k; i++){
upd(op[i - 1], 1, 1, n, left[i - 1] + 1, right[i - 1] + 1, height[i - 1]);
}
get(1, 1, n);
for (int i = 1; i <= n; i++) finalHeight[i - 1] = res[i];
}
/*
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("time.in", "r")){
freopen("time.in", "r", stdin);
freopen("time.out", "w", stdout);
}
int tc, n; cin >> n >> tc;
build(1, 1, n);
while(tc--){
int le, ri, op, h;
cin >> op >> le >> ri >> h;
upd(op, 1, 1, n, le + 1, ri + 1, h);
}
comp(1, 1, n);
for(int i = 1; i <= n; ++i)
cout << res[i] << ' ';
}
/*
*/
Compilation message
wall.cpp:102:1: warning: "/*" within comment [-Wcomment]
102 | /*
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
8 ms |
1152 KB |
Output is correct |
5 |
Correct |
8 ms |
1152 KB |
Output is correct |
6 |
Correct |
7 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
171 ms |
8160 KB |
Output is correct |
3 |
Correct |
253 ms |
4876 KB |
Output is correct |
4 |
Correct |
753 ms |
13244 KB |
Output is correct |
5 |
Correct |
393 ms |
13816 KB |
Output is correct |
6 |
Correct |
366 ms |
13816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
1024 KB |
Output is correct |
5 |
Correct |
7 ms |
1024 KB |
Output is correct |
6 |
Correct |
8 ms |
1024 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
216 ms |
8184 KB |
Output is correct |
9 |
Correct |
328 ms |
4860 KB |
Output is correct |
10 |
Correct |
783 ms |
13304 KB |
Output is correct |
11 |
Correct |
427 ms |
13760 KB |
Output is correct |
12 |
Correct |
371 ms |
13852 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
176 ms |
8184 KB |
Output is correct |
15 |
Correct |
49 ms |
2040 KB |
Output is correct |
16 |
Correct |
916 ms |
13504 KB |
Output is correct |
17 |
Correct |
376 ms |
13504 KB |
Output is correct |
18 |
Correct |
378 ms |
13560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
8 ms |
1024 KB |
Output is correct |
5 |
Correct |
7 ms |
1024 KB |
Output is correct |
6 |
Correct |
7 ms |
1024 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
202 ms |
8244 KB |
Output is correct |
9 |
Correct |
242 ms |
4856 KB |
Output is correct |
10 |
Correct |
730 ms |
13304 KB |
Output is correct |
11 |
Correct |
383 ms |
13816 KB |
Output is correct |
12 |
Correct |
391 ms |
13820 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
190 ms |
8216 KB |
Output is correct |
15 |
Correct |
39 ms |
2040 KB |
Output is correct |
16 |
Correct |
746 ms |
13692 KB |
Output is correct |
17 |
Correct |
385 ms |
13560 KB |
Output is correct |
18 |
Correct |
374 ms |
13560 KB |
Output is correct |
19 |
Correct |
1047 ms |
99960 KB |
Output is correct |
20 |
Correct |
1042 ms |
97528 KB |
Output is correct |
21 |
Correct |
1048 ms |
99960 KB |
Output is correct |
22 |
Correct |
1041 ms |
97656 KB |
Output is correct |
23 |
Correct |
1018 ms |
97532 KB |
Output is correct |
24 |
Correct |
1012 ms |
97528 KB |
Output is correct |
25 |
Correct |
1035 ms |
97528 KB |
Output is correct |
26 |
Correct |
1046 ms |
100128 KB |
Output is correct |
27 |
Correct |
1032 ms |
100088 KB |
Output is correct |
28 |
Correct |
1037 ms |
97528 KB |
Output is correct |
29 |
Correct |
1016 ms |
97528 KB |
Output is correct |
30 |
Correct |
1026 ms |
97656 KB |
Output is correct |