# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
795817 |
2023-07-27T16:23:00 Z |
idiotcomputer |
Wall (IOI14_wall) |
C++11 |
|
150 ms |
17468 KB |
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;
const int MAX_N = 20000;
const int NINF = 0;
const int INF = (1<<30);
struct node {
int opmin = INF;
int opmax = NINF;
};
node segt[4*MAX_N+1];
void app(int idx, node a){
segt[idx].opmax = min(max(segt[idx].opmax,a.opmax), a.opmin);
segt[idx].opmin = min(max(segt[idx].opmin,a.opmax),a.opmin);
return;
}
void upd(int l, int r, int idx, int tl, int tr, int w, int h){
if (l > tr || r < tl){
return;
}
if (l >= tl && r <= tr){
//mini
if (w == 1){
segt[idx].opmin = min(segt[idx].opmin,h);
segt[idx].opmax = min(segt[idx].opmax,h);
} else {
segt[idx].opmin = max(segt[idx].opmin,h);
segt[idx].opmax = max(segt[idx].opmax,h);
}
return;
}
int m = (l+r)/2;
app(2*idx+1,segt[idx]);
app(2*idx+2,segt[idx]);
segt[idx].opmin = INF;
segt[idx].opmax = NINF;
upd(l,m,2*idx+1,tl,tr,w,h);
upd(m+1,r,2*idx+2,tl,tr,w,h);
return;
}
void solve(int l, int r, int idx, int finalHeight[]){
if (l == r){
//cout << l << ": " << segt[idx].opmin << ", " << segt[idx].opmax << '\n';
if (segt[idx].opmin == INF && segt[idx].opmax == NINF){
finalHeight[l] = 0;
} else {
finalHeight[l] = min(segt[idx].opmin,segt[idx].opmax);
}
return;
}
int m = (l+r)/2;
app(2*idx+1,segt[idx]);
app(2*idx+2,segt[idx]);
segt[idx].opmin = INF;
segt[idx].opmax = NINF;
solve(l,m,2*idx+1,finalHeight);
solve(m+1,r,2*idx+2,finalHeight);
return;
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for (int i =0; i < k; i++){
upd(0,n-1,0,left[i],right[i],op[i]-1,height[i]);
}
solve(0,n-1,0,finalHeight);
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
4 ms |
724 KB |
Output is correct |
5 |
Correct |
4 ms |
724 KB |
Output is correct |
6 |
Correct |
4 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
101 ms |
8400 KB |
Output is correct |
3 |
Correct |
122 ms |
4380 KB |
Output is correct |
4 |
Runtime error |
124 ms |
17468 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
368 KB |
Output is correct |
4 |
Correct |
4 ms |
764 KB |
Output is correct |
5 |
Correct |
4 ms |
760 KB |
Output is correct |
6 |
Correct |
4 ms |
736 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
101 ms |
8284 KB |
Output is correct |
9 |
Correct |
115 ms |
4380 KB |
Output is correct |
10 |
Runtime error |
150 ms |
17444 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
4 ms |
724 KB |
Output is correct |
5 |
Correct |
4 ms |
768 KB |
Output is correct |
6 |
Correct |
4 ms |
724 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
112 ms |
8332 KB |
Output is correct |
9 |
Correct |
125 ms |
4412 KB |
Output is correct |
10 |
Runtime error |
126 ms |
17444 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |