# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
939719 |
2024-03-06T16:58:15 Z |
asdasdqwer |
Wall (IOI14_wall) |
C++14 |
|
3000 ms |
13924 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
struct Segtree {
int n;
vector<int> lzMin, lzMax;
const int minConst = 1e9;
const int maxConst = 0;
Segtree(int sz) {
n=1;
while(n<sz)n*=2;
lzMin.assign(2*n,minConst);
lzMax.assign(2*n,maxConst);
}
void pushdown(int x) {
if (lzMin[x] == minConst && lzMax[x] == maxConst) {
return;
}
lzMin[2*x+1] = min(lzMin[2*x+1], lzMin[x]);
lzMin[2*x+2] = min(lzMin[2*x+2], lzMin[x]);
lzMax[2*x+1] = max(lzMax[2*x+1], lzMax[x]);
lzMax[2*x+2] = max(lzMax[2*x+2], lzMax[x]);
if (lzMax[x] > lzMin[2*x+1]) {
lzMin[2*x+1] = lzMax[x];
}
if (lzMax[x] > lzMin[2*x+2]) {
lzMin[2*x+2] = lzMax[x];
}
if (lzMin[x] < lzMax[2*x+1]) {
lzMax[2*x+1] = lzMin[x];
}
if (lzMin[x] < lzMax[2*x+2]) {
lzMax[2*x+2] = lzMin[x];
}
lzMin[x] = minConst;
lzMax[x] = maxConst;
}
void set(int l, int r, int v, int x, int lx, int rx, bool isMax=false) {
if (lx >= r || rx <= l) return;
if (rx - lx == 1) {
if (isMax) {
if (lzMax[x] < v) {
lzMax[x] = v;
}
if (lzMin[x] < v) {
lzMin[x] = v;
}
}
else {
if (lzMin[x] > v) {
lzMin[x] = v;
}
if (lzMax[x] > v) {
lzMax[x] = v;
}
}
return;
}
pushdown(x);
if (lx >= l && rx <= r) {
if (isMax) {
if (lzMax[x] < v) {
lzMax[x] = v;
}
if (lzMin[x] < v) {
lzMin[x] = v;
}
}
else {
if (lzMin[x] > v) {
lzMin[x] = v;
}
if (lzMax[x] > v) {
lzMax[x] = v;
}
}
return;
}
int m=(lx+rx)/2;
set(l, r, v, 2*x+1, lx, m, isMax);
set(l, r, v, 2*x+2, m, rx, isMax);
}
void setMax(int l, int r, int v) {
set(l, r, v, 0, 0, n, true);
}
void setMin(int l, int r, int v) {
set(l, r, v, 0, 0, n, false);
}
int get(int i, int x, int lx, int rx) {
if (rx-lx==1) {
return lzMax[x];
}
pushdown(x);
int m=(lx+rx)/2;
if (i<m)return get(i,2*x+1,lx,m);
else return get(i,2*x+2,m,rx);
}
int get(int i) {
return get(i,0,0,n);
}
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
Segtree sg(n);
for (int i=0;i<k;i++) {
if (op[i] == 1) {
sg.setMax(left[i], right[i]+1, height[i]);
}
else {
sg.setMin(left[i], right[i]+1, height[i]);
}
vector<int> out;
for (int i=0;i<n;i++) {
out.push_back(sg.get(i));
}
}
for (int i=0;i<n;i++) {
finalHeight[i] = sg.get(i);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
436 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
15 ms |
348 KB |
Output is correct |
4 |
Correct |
2688 ms |
992 KB |
Output is correct |
5 |
Correct |
2640 ms |
992 KB |
Output is correct |
6 |
Correct |
2682 ms |
992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
110 ms |
13820 KB |
Output is correct |
3 |
Execution timed out |
3035 ms |
7436 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
572 KB |
Output is correct |
3 |
Correct |
12 ms |
348 KB |
Output is correct |
4 |
Correct |
2686 ms |
996 KB |
Output is correct |
5 |
Correct |
2693 ms |
996 KB |
Output is correct |
6 |
Correct |
2639 ms |
1108 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
110 ms |
13924 KB |
Output is correct |
9 |
Execution timed out |
3017 ms |
8548 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
12 ms |
348 KB |
Output is correct |
4 |
Correct |
2631 ms |
996 KB |
Output is correct |
5 |
Correct |
2633 ms |
860 KB |
Output is correct |
6 |
Correct |
2637 ms |
1108 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
113 ms |
13856 KB |
Output is correct |
9 |
Execution timed out |
3065 ms |
8480 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |