# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
798156 |
2023-07-30T12:13:52 Z |
QwertyPi |
Wall (IOI14_wall) |
C++14 |
|
413 ms |
32444 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
struct range{
int l, r;
range operator+ (const range& o) const {
if(r < o.l) return {o.l, o.l};
if(l > o.r) return {o.r, o.r};
return {max(o.l, l), min(o.r, r)};
}
};
range t[1 << 21];
int k;
void build(int v = 0, int l = 0, int r = k - 1){
if(l == r) return void(t[v] = {0, INF});
int m = (l + r) / 2;
build(v * 2 + 1, l, m); build(v * 2 + 2, m + 1, r);
t[v] = t[v * 2 + 1] + t[v * 2 + 2];
}
void update(int p, int op, int h, int v = 0, int l = 0, int r = k - 1){
if(l == r){
if(op == 0) t[v] = {-INF, INF};
else if(op == 1) t[v] = {h, INF};
else t[v] = {0, h};
return;
}
int m = (l + r) / 2;
if(p <= m) update(p, op, h, v * 2 + 1, l, m);
else update(p, op, h, v * 2 + 2, m + 1, r);
t[v] = t[v * 2 + 1] + t[v * 2 + 2];
}
struct query{
int t, p, op, h;
bool operator< (const query& o) const {
return t < o.t;
}
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
::k = k;
vector<query> Q;
for(int i = 0; i < k; i++){
Q.push_back({left[i], i, op[i], height[i]});
Q.push_back({right[i] + 1, i, 0, height[i]});
}
build();
sort(Q.begin(), Q.end());
int qi = 0;
for(int i = 0; i < n; i++){
while(qi < Q.size() && Q[qi].t <= i) update(Q[qi].p, Q[qi].op, Q[qi].h), qi++;
finalHeight[i] = t[0].l;
}
return;
}
Compilation message
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:56:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<query>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | while(qi < Q.size() && Q[qi].t <= i) update(Q[qi].p, Q[qi].op, Q[qi].h), qi++;
| ~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
724 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
5 ms |
728 KB |
Output is correct |
5 |
Correct |
4 ms |
728 KB |
Output is correct |
6 |
Incorrect |
4 ms |
728 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
206 ms |
32096 KB |
Output is correct |
3 |
Correct |
169 ms |
14348 KB |
Output is correct |
4 |
Correct |
413 ms |
32444 KB |
Output is correct |
5 |
Incorrect |
313 ms |
32404 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
724 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
4 ms |
728 KB |
Output is correct |
5 |
Correct |
4 ms |
728 KB |
Output is correct |
6 |
Incorrect |
4 ms |
728 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
724 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
4 ms |
728 KB |
Output is correct |
5 |
Correct |
4 ms |
728 KB |
Output is correct |
6 |
Incorrect |
4 ms |
728 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |