# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
302940 |
2020-09-19T13:27:09 Z |
wiwiho |
벽 (IOI14_wall) |
C++14 |
|
1047 ms |
99576 KB |
//#define NDEBUG
#include "wall.h"
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
if(pvaspace) b << " "; pvaspace=true;\
b << pva;\
}\
b << "\n";}
//#define TEST
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;
const ll MOD = 1000000007;
const ll MAX = 2147483647;
template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
return o << '(' << p.F << ',' << p.S << ')';
}
struct Node{
int l = -1, r = -1, mx = 0, mn = 0;
};
vector<Node> st;
int ts = 0;
int build(int l, int r){
int id = ts++;
if(l == r) return id;
int m = (l + r) / 2;
st[id].l = build(l, m);
st[id].r = build(m + 1, r);
return id;
}
void push(int id){
if(st[id].l == -1) return;
int l = st[id].l, r = st[id].r;
if(max(st[l].mn, st[id].mn) <= min(st[l].mx, st[id].mx)){
st[l].mn = max(st[l].mn, st[id].mn);
st[l].mx = min(st[l].mx, st[id].mx);
}
else if(st[l].mx < st[id].mn) st[l].mn = st[l].mx = st[id].mn;
else st[l].mn = st[l].mx = st[id].mx;
if(max(st[r].mn, st[id].mn) <= min(st[r].mx, st[id].mx)){
st[r].mn = max(st[r].mn, st[id].mn);
st[r].mx = min(st[r].mx, st[id].mx);
}
else if(st[r].mx < st[id].mn) st[r].mn = st[r].mx = st[id].mn;
else st[r].mn = st[r].mx = st[id].mx;
}
void modifyadd(int l, int r, int v, int L, int R, int id){
push(id);
if(L == l && R == r){
st[id].mn = max(st[id].mn, v);
st[id].mx = max(st[id].mx, st[id].mn);
return;
}
int M = (L + R) / 2;
if(r <= M) modifyadd(l, r, v, L, M, st[id].l);
else if(l > M) modifyadd(l, r, v, M + 1, R, st[id].r);
else{
modifyadd(l, M, v, L, M, st[id].l);
modifyadd(M + 1, r, v, M + 1, R, st[id].r);
}
st[id].mn = min(st[st[id].l].mn, st[st[id].r].mn);
st[id].mx = max(st[st[id].l].mx, st[st[id].r].mx);
}
void modifyremove(int l, int r, int v, int L, int R, int id){
if(L == l && R == r){
st[id].mx = min(st[id].mx, v);
st[id].mn = min(st[id].mx, st[id].mn);
return;
}
push(id);
int M = (L + R) / 2;
if(r <= M) modifyremove(l, r, v, L, M, st[id].l);
else if(l > M) modifyremove(l, r, v, M + 1, R, st[id].r);
else{
modifyremove(l, M, v, L, M, st[id].l);
modifyremove(M + 1, r, v, M + 1, R, st[id].r);
}
st[id].mn = min(st[st[id].l].mn, st[st[id].r].mn);
st[id].mx = max(st[st[id].l].mx, st[st[id].r].mx);
}
void dfs(int L, int R, int id, int finalHeight[]){
if(L == R){
finalHeight[L] = st[id].mn;
return;
}
push(id);
int M = (L + R) / 2;
dfs(L, M, st[id].l, finalHeight);
dfs(M + 1, R, st[id].r, finalHeight);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
st.resize(2 * n);
build(0, n - 1);
for(int i = 0; i < k; i++){
if(op[i] == 1){
modifyadd(left[i], right[i], height[i], 0, n - 1, 0);
}
else{
modifyremove(left[i], right[i], height[i], 0, n - 1, 0);
}
}
dfs(0, n - 1, 0, finalHeight);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 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 |
896 KB |
Output is correct |
5 |
Correct |
9 ms |
896 KB |
Output is correct |
6 |
Correct |
7 ms |
896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
182 ms |
13944 KB |
Output is correct |
3 |
Correct |
251 ms |
8040 KB |
Output is correct |
4 |
Correct |
671 ms |
21508 KB |
Output is correct |
5 |
Correct |
405 ms |
22524 KB |
Output is correct |
6 |
Correct |
377 ms |
21056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
8 ms |
896 KB |
Output is correct |
5 |
Correct |
7 ms |
896 KB |
Output is correct |
6 |
Correct |
7 ms |
896 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
179 ms |
13908 KB |
Output is correct |
9 |
Correct |
251 ms |
8048 KB |
Output is correct |
10 |
Correct |
690 ms |
21464 KB |
Output is correct |
11 |
Correct |
406 ms |
22552 KB |
Output is correct |
12 |
Correct |
379 ms |
20984 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
179 ms |
13936 KB |
Output is correct |
15 |
Correct |
42 ms |
2040 KB |
Output is correct |
16 |
Correct |
784 ms |
21752 KB |
Output is correct |
17 |
Correct |
391 ms |
21240 KB |
Output is correct |
18 |
Correct |
402 ms |
21240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
9 ms |
1024 KB |
Output is correct |
5 |
Correct |
7 ms |
896 KB |
Output is correct |
6 |
Correct |
7 ms |
896 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
196 ms |
13972 KB |
Output is correct |
9 |
Correct |
252 ms |
8056 KB |
Output is correct |
10 |
Correct |
687 ms |
21492 KB |
Output is correct |
11 |
Correct |
422 ms |
22520 KB |
Output is correct |
12 |
Correct |
380 ms |
20944 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
185 ms |
13944 KB |
Output is correct |
15 |
Correct |
42 ms |
2168 KB |
Output is correct |
16 |
Correct |
823 ms |
21752 KB |
Output is correct |
17 |
Correct |
390 ms |
21116 KB |
Output is correct |
18 |
Correct |
384 ms |
21112 KB |
Output is correct |
19 |
Correct |
1026 ms |
99452 KB |
Output is correct |
20 |
Correct |
1012 ms |
97012 KB |
Output is correct |
21 |
Correct |
1033 ms |
99576 KB |
Output is correct |
22 |
Correct |
1000 ms |
96888 KB |
Output is correct |
23 |
Correct |
1002 ms |
97016 KB |
Output is correct |
24 |
Correct |
1047 ms |
96888 KB |
Output is correct |
25 |
Correct |
1008 ms |
96888 KB |
Output is correct |
26 |
Correct |
1027 ms |
99320 KB |
Output is correct |
27 |
Correct |
1022 ms |
99448 KB |
Output is correct |
28 |
Correct |
1010 ms |
96888 KB |
Output is correct |
29 |
Correct |
1024 ms |
97016 KB |
Output is correct |
30 |
Correct |
1020 ms |
97016 KB |
Output is correct |