# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
159307 |
2019-10-22T09:08:45 Z |
TAISA_ |
Wall (IOI14_wall) |
C++14 |
|
178 ms |
14072 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Segtree {
int n;
vector<pair<int, P>> dat;
vector<int> s;
Segtree(int n_) {
n = 1;
while (n < n_) {
n <<= 1;
}
dat.resize(2 * n, make_pair(-1, P(-1, -1)));
s.resize(2 * n, -1);
}
void upd(int a, int b, P x, int t, int k, int l, int r) {
if (b <= l || r <= a) {
return;
}
if (a <= l && r <= b) {
if (x.second == 1) {
if (s[k] < x.first) {
dat[k] = make_pair(t, x);
s[k] = x.first;
}
} else {
if (s[k] == -1 || s[k] > x.first) {
dat[k] = make_pair(t, x);
s[k] = x.first;
}
}
return;
}
upd(a, b, x, t, k << 1, l, (l + r) >> 1);
upd(a, b, x, t, k << 1 | 1, (l + r) >> 1, r);
}
void upd(int a, int b, P x, int t) { upd(a, b, x, t, 1, 0, n); }
vector<pair<int, P>> get(int k) {
k += n;
vector<pair<int, P>> res;
if (dat[k].first != -1) {
res.push_back(dat[k]);
}
k >>= 1;
while (k > 0) {
if (dat[k].first != -1) {
res.push_back(dat[k]);
}
k >>= 1;
}
sort(res.begin(), res.end());
return res;
}
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[],
int finalHeight[]) {
if (k <= 5000 && n <= 10000) {
for (int i = 0; i < n; i++) {
finalHeight[i] = 0;
}
for (int i = 0; i < k; i++) {
for (int j = left[i]; j <= right[i]; j++) {
if (op[i] == 1) {
finalHeight[j] = max(finalHeight[j], height[i]);
} else {
finalHeight[j] = min(finalHeight[j], height[i]);
}
}
}
} else {
Segtree seg(n);
for (int i = 0; i < k; i++) {
seg.upd(left[i], right[i] + 1, P(height[i], op[i]), i);
}
for (int i = 0; i < n; i++) {
int t = 0;
vector<pair<int, P>> v = seg.get(i);
for (auto &p : v) {
if (p.second.second == 1) {
t = max(t, p.second.first);
} else {
t = min(t, p.second.first);
}
}
finalHeight[i] = t;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
25 ms |
504 KB |
Output is correct |
5 |
Correct |
25 ms |
632 KB |
Output is correct |
6 |
Correct |
25 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
174 ms |
8184 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
25 ms |
560 KB |
Output is correct |
5 |
Correct |
25 ms |
560 KB |
Output is correct |
6 |
Correct |
25 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Incorrect |
176 ms |
14072 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
424 KB |
Output is correct |
4 |
Correct |
27 ms |
632 KB |
Output is correct |
5 |
Correct |
25 ms |
760 KB |
Output is correct |
6 |
Correct |
26 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Incorrect |
178 ms |
13944 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |