# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
751871 |
2023-06-01T17:13:33 Z |
adrilen |
Wall (IOI14_wall) |
C++17 |
|
159 ms |
13852 KB |
#include "wall.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
constexpr int maxn = 15, bit = 32 - __builtin_clz(maxn), siz = 1 << bit;
struct Node {
int val;
bool empty, is_max, fini;
void comp(const Node &other) {
if (other.empty) return ;
if (empty || other.fini) {
val = other.val, empty = other.empty, is_max = other.is_max, fini = other.fini;
}
else if (is_max)
{
if (other.is_max)
{
val = max(val, other.val);
} else {
if (other.val < val)
{
val = other.val;
is_max = false;
fini = true;
}
}
} else {
if (other.is_max)
{
if (other.val > val)
{
val = other.val;
is_max = true;
fini = true;
}
} else {
val = min(val, other.val);
}
}
}
bool operator==(const Node &right) const
{
return (val == right.val) && (empty == right.empty) && (is_max == right.is_max) && (fini == right.fini);
}
} ;
Node defa = Node{0, true, false, false};
Node segtree[siz * 2] = { 0 };
void propogate(int pos)
{
segtree[pos * 2].comp(segtree[pos]);
segtree[pos * 2 + 1].comp(segtree[pos]);
segtree[pos] = defa;
}
void update(int pos, int l, int r, int gl, int gr, Node p)
{
if (gl > r || l > gr) return ;
Node test = segtree[pos];
test.comp(p);
if (test == segtree[pos]) return;
// Inside
if (gl <= l && r <= gr)
{
segtree[pos].comp(p);
return ;
}
propogate(pos);
int mid = (l + r) >> 1;
update(pos * 2, l, mid, gl, gr, p);
update(pos * 2 + 1, mid + 1, r, gl, gr, p);
}
int output[maxn] = { 0 };
void fnd_answers(int pos, int l, int r, int gl, int gr)
{
// cout << pos << "\n";
if (l > gr || gl > r) return ;
// cout << pos << endl;
if (segtree[pos].fini)
{
for (int i = l; i <= r; i++) output[i] = segtree[pos].val;
// cout << "finished: " <<l << " " << r << "\n";
return ;
}
propogate(pos);
int mid = (l + r) >> 1;
fnd_answers(pos * 2, l, mid, gl, gr);
fnd_answers(pos * 2 + 1, mid + 1, r, gl, gr);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
// for (int i = 1; i < siz; i++) segtree[i].empty = false;
for (int i = siz; i < siz + n; i++) segtree[i].fini = true;
for (int i = 0; i < k; i++)
{
// cout << i << "\n";
update(1, 0, siz - 1, left[i], right[i], Node{height[i], false, (bool)(op[i] & 1), false});
// for (int i = 1; i < 2 * siz; i++)
// {
// if (__builtin_popcount(i) == 1) cout << "\n";
// cout << segtree[i].val << " " << segtree[i].is_max << " " << segtree[i].empty << " " << segtree[i].fini << " ";
// }
// cout << "\n\n";
}
fnd_answers(1, 0, siz - 1, 0, n - 1);
for (int i = 0; i < n; i++) finalHeight[i] = output[i];
return ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
159 ms |
13852 KB |
Output is correct |
3 |
Runtime error |
98 ms |
10840 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
312 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
436 KB |
Output is correct |
3 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |