# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
387523 |
2021-04-08T18:15:22 Z |
peijar |
벽 (IOI14_wall) |
C++17 |
|
2227 ms |
119148 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 8e6;
const int INF = 1e9;
int segVal[MAXN], lazyMax[MAXN], lazyMin[MAXN];
int iDeb[MAXN], iFin[MAXN];
void buildTree(int iNoeud, int li, int ri)
{
iDeb[iNoeud] = li, iFin[iNoeud] = ri;
lazyMax[iNoeud] = 0;
lazyMin[iNoeud] = INF;
if (li == ri)
return;
buildTree(2*iNoeud, li, (li+ri)/2);
buildTree(2*iNoeud+1, (li+ri)/2+1, ri);
}
void changeMax(int iNoeud, int val)
{
lazyMax[iNoeud] = max(lazyMax[iNoeud], val);
lazyMin[iNoeud] = max(lazyMin[iNoeud], val);
}
void changeMin(int iNoeud, int val)
{
lazyMin[iNoeud] = min(lazyMin[iNoeud], val);
lazyMax[iNoeud] = min(lazyMax[iNoeud], val);
}
void pushDown(int iNoeud)
{
segVal[iNoeud] = max(segVal[iNoeud], lazyMax[iNoeud]);
segVal[iNoeud] = min(segVal[iNoeud], lazyMin[iNoeud]);
if (iDeb[iNoeud] < iFin[iNoeud])
{
changeMax(2*iNoeud, lazyMax[iNoeud]);
changeMin(2*iNoeud, lazyMin[iNoeud]);
changeMax(2*iNoeud+1, lazyMax[iNoeud]);
changeMin(2*iNoeud+1, lazyMin[iNoeud]);
}
lazyMax[iNoeud] = 0, lazyMin[iNoeud] = INF;
}
int getVal(int iNoeud, int pos)
{
pushDown(iNoeud);
if (iDeb[iNoeud] > pos or iFin[iNoeud] < pos) return 0;
if (iDeb[iNoeud] == iFin[iNoeud])
return segVal[iNoeud];
return getVal(2*iNoeud, pos) + getVal(2*iNoeud+1, pos);
}
void update(int iNoeud, int deb, int fin, int op, int val)
{
pushDown(iNoeud);
if (deb > iFin[iNoeud] or fin < iDeb[iNoeud])
return;
if (deb <= iDeb[iNoeud] and iFin[iNoeud] <= fin)
{
if (op==1)
lazyMax[iNoeud] = val;
else
lazyMin[iNoeud] = val;
pushDown(iNoeud);
return ;
}
update(2*iNoeud, deb, fin, op, val);
update(2*iNoeud+1, deb, fin, op, val);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
buildTree(1, 0, n-1);
for (int i(0); i < k; ++i)
update(1, left[i], right[i], op[i], height[i]);
for (int i(0); i < n; ++i)
finalHeight[i] = getVal(1, i);
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
3 ms |
620 KB |
Output is correct |
3 |
Correct |
3 ms |
492 KB |
Output is correct |
4 |
Correct |
13 ms |
1260 KB |
Output is correct |
5 |
Correct |
11 ms |
1260 KB |
Output is correct |
6 |
Correct |
11 ms |
1260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
167 ms |
9708 KB |
Output is correct |
3 |
Correct |
265 ms |
6528 KB |
Output is correct |
4 |
Correct |
837 ms |
15084 KB |
Output is correct |
5 |
Correct |
482 ms |
15580 KB |
Output is correct |
6 |
Correct |
481 ms |
15724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
3 ms |
492 KB |
Output is correct |
4 |
Correct |
12 ms |
1260 KB |
Output is correct |
5 |
Correct |
11 ms |
1260 KB |
Output is correct |
6 |
Correct |
11 ms |
1260 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
162 ms |
9580 KB |
Output is correct |
9 |
Correct |
264 ms |
6508 KB |
Output is correct |
10 |
Correct |
830 ms |
15084 KB |
Output is correct |
11 |
Correct |
485 ms |
15724 KB |
Output is correct |
12 |
Correct |
471 ms |
15724 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
162 ms |
9636 KB |
Output is correct |
15 |
Correct |
48 ms |
2796 KB |
Output is correct |
16 |
Correct |
862 ms |
15468 KB |
Output is correct |
17 |
Correct |
482 ms |
15340 KB |
Output is correct |
18 |
Correct |
470 ms |
15340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
3 ms |
492 KB |
Output is correct |
4 |
Correct |
12 ms |
1260 KB |
Output is correct |
5 |
Correct |
11 ms |
1260 KB |
Output is correct |
6 |
Correct |
11 ms |
1260 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
162 ms |
9580 KB |
Output is correct |
9 |
Correct |
262 ms |
6508 KB |
Output is correct |
10 |
Correct |
854 ms |
15104 KB |
Output is correct |
11 |
Correct |
479 ms |
15596 KB |
Output is correct |
12 |
Correct |
471 ms |
15724 KB |
Output is correct |
13 |
Correct |
1 ms |
372 KB |
Output is correct |
14 |
Correct |
162 ms |
9580 KB |
Output is correct |
15 |
Correct |
47 ms |
2796 KB |
Output is correct |
16 |
Correct |
837 ms |
15340 KB |
Output is correct |
17 |
Correct |
482 ms |
15340 KB |
Output is correct |
18 |
Correct |
481 ms |
15408 KB |
Output is correct |
19 |
Correct |
2144 ms |
109616 KB |
Output is correct |
20 |
Correct |
2147 ms |
116528 KB |
Output is correct |
21 |
Correct |
2155 ms |
118968 KB |
Output is correct |
22 |
Correct |
2148 ms |
116624 KB |
Output is correct |
23 |
Correct |
2145 ms |
116596 KB |
Output is correct |
24 |
Correct |
2147 ms |
116460 KB |
Output is correct |
25 |
Correct |
2160 ms |
116652 KB |
Output is correct |
26 |
Correct |
2154 ms |
119148 KB |
Output is correct |
27 |
Correct |
2227 ms |
119056 KB |
Output is correct |
28 |
Correct |
2185 ms |
116532 KB |
Output is correct |
29 |
Correct |
2164 ms |
116432 KB |
Output is correct |
30 |
Correct |
2159 ms |
116428 KB |
Output is correct |