# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
297686 |
2020-09-11T18:19:05 Z |
kevlee |
벽 (IOI14_wall) |
C++17 |
|
1020 ms |
85496 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a))
#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
//max, min, current mode
struct node {
int max, min;
} lazy[8000005], upd;
int seg[8000005];
int ans[2000005];
void merge(node b, node& a) { //update a with b
a.max = min(max(a.max, b.max), b.min);
a.min = min(max(a.min, b.max), b.min);
}
void pushdown(int id, int l, int r) {
seg[id] = max(seg[id], lazy[id].max);
seg[id] = min(seg[id], lazy[id].min);
if (l != r) {
merge(lazy[id], lazy[id * 2]);
merge(lazy[id], lazy[id * 2 + 1]);
}
lazy[id].max = 0;
lazy[id].min = inf;
}
void update(int id, int l, int r, int ql, int qr) {
pushdown(id, l, r);
if (ql > r || qr < l) return;
if (ql <= l && r <= qr) {
merge(upd, lazy[id]);
pushdown(id, l, r);
return;
}
int mid = (l + r) >> 1;
update(id * 2, l, mid, ql, qr);
update(id * 2 + 1, mid + 1, r, ql, qr);
}
void query(int id, int l, int r) {
pushdown(id, l, r);
if (l == r) {
ans[l] = seg[id];
return;
}
int mid = (l + r) >> 1;
query(id * 2, l, mid);
query(id * 2 + 1, mid + 1, r);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
FOR(i, 0, k-1) {
left[i]++;
right[i]++;
if (op[i] == 1) {
upd = {height[i], inf};
update(1, 1, n, left[i], right[i]);
} else {
upd = {0, height[i]};
update(1, 1, n, left[i], right[i]);
}
}
query(1, 1, n);
FOR(i, 0, n-1) finalHeight[i] = ans[i+1];
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
288 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
2 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 |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
175 ms |
11128 KB |
Output is correct |
3 |
Correct |
232 ms |
6008 KB |
Output is correct |
4 |
Correct |
674 ms |
15224 KB |
Output is correct |
5 |
Correct |
398 ms |
15736 KB |
Output is correct |
6 |
Correct |
385 ms |
15736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 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 |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
179 ms |
10360 KB |
Output is correct |
9 |
Correct |
233 ms |
6684 KB |
Output is correct |
10 |
Correct |
676 ms |
14200 KB |
Output is correct |
11 |
Correct |
391 ms |
14524 KB |
Output is correct |
12 |
Correct |
387 ms |
14700 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
173 ms |
10232 KB |
Output is correct |
15 |
Correct |
41 ms |
2552 KB |
Output is correct |
16 |
Correct |
738 ms |
14460 KB |
Output is correct |
17 |
Correct |
390 ms |
14456 KB |
Output is correct |
18 |
Correct |
387 ms |
14584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 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 |
176 ms |
10340 KB |
Output is correct |
9 |
Correct |
228 ms |
6776 KB |
Output is correct |
10 |
Correct |
670 ms |
14200 KB |
Output is correct |
11 |
Correct |
395 ms |
14584 KB |
Output is correct |
12 |
Correct |
386 ms |
14840 KB |
Output is correct |
13 |
Correct |
1 ms |
512 KB |
Output is correct |
14 |
Correct |
180 ms |
10360 KB |
Output is correct |
15 |
Correct |
43 ms |
2680 KB |
Output is correct |
16 |
Correct |
768 ms |
14456 KB |
Output is correct |
17 |
Correct |
401 ms |
14456 KB |
Output is correct |
18 |
Correct |
382 ms |
14456 KB |
Output is correct |
19 |
Correct |
965 ms |
85112 KB |
Output is correct |
20 |
Correct |
970 ms |
82812 KB |
Output is correct |
21 |
Correct |
969 ms |
85496 KB |
Output is correct |
22 |
Correct |
977 ms |
82780 KB |
Output is correct |
23 |
Correct |
967 ms |
82936 KB |
Output is correct |
24 |
Correct |
1020 ms |
82936 KB |
Output is correct |
25 |
Correct |
971 ms |
82728 KB |
Output is correct |
26 |
Correct |
968 ms |
85368 KB |
Output is correct |
27 |
Correct |
982 ms |
85404 KB |
Output is correct |
28 |
Correct |
968 ms |
82808 KB |
Output is correct |
29 |
Correct |
969 ms |
82916 KB |
Output is correct |
30 |
Correct |
977 ms |
82680 KB |
Output is correct |