# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
166138 |
2019-11-30T22:32:37 Z |
tri |
Wall (IOI14_wall) |
C++14 |
|
795 ms |
75216 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
#define pb push_back
#define f first
#define s second
namespace debug {
const int DEBUG = true;
template<class T1, class T2>
void pr(const pair<T1, T2> &x);
template<class T, size_t SZ>
void pr(const array<T, SZ> &x);
template<class T>
void pr(const vector<T> &x);
template<class T>
void pr(const set<T> &x);
template<class T1, class T2>
void pr(const map<T1, T2> &x);
template<class T>
void pr(const T &x) { if (DEBUG) cout << x; }
template<class T, class... Ts>
void pr(const T &first, const Ts &... rest) { pr(first), pr(rest...); }
template<class T1, class T2>
void pr(const pair<T1, T2> &x) { pr("{", x.f, ", ", x.s, "}"); }
template<class T>
void prIn(const T &x) {
pr("{");
bool fst = 1;
for (auto &a : x) {
pr(fst ? "" : ", ", a), fst = 0;
}
pr("}");
}
template<class T, size_t SZ>
void pr(const array<T, SZ> &x) { prIn(x); }
template<class T>
void pr(const vector<T> &x) { prIn(x); }
template<class T>
void pr(const set<T> &x) { prIn(x); }
template<class T1, class T2>
void pr(const map<T1, T2> &x) { prIn(x); }
void ps() { pr("\n"), cout << flush; }
template<class Arg, class... Args>
void ps(const Arg &first, const Args &... rest) {
pr(first, " ");
ps(rest...);
}
}
using namespace debug;
const int MAXN = 2000100;
struct Restrict {
int l, u;
Restrict operator+(Restrict o) {
int nL = max(l, o.l);
int nU = max(u, o.l);
nU = min(nU, o.u);
nL = min(nL, o.u);
return {nL, nU};
}
void operator+=(Restrict o) {
int nL = max(l, o.l);
int nU = max(u, o.l);
nU = min(nU, o.u);
nL = min(nL, o.u);
l = nL;
u = nU;
}
bool operator==(Restrict o) {
return l == o.l && u == o.u;
}
};
Restrict ID = {(int) -1e9, (int) 1e9};
struct SegTr {
Restrict tr[4 * MAXN];
void push(int i, int l, int r) {
if (tr[i] == ID || l == r) return;
tr[i * 2] += tr[i];
tr[i * 2 + 1] += tr[i];
tr[i] = ID;
}
void u(int i, int l, int r, int s, int e, Restrict d) {
if (e < l || r < s) {
return;
}
if (s <= l && r <= e) {
tr[i] += d;
return;
}
push(i, l, r);
int mid = (l + r) / 2;
u(i * 2, l, mid, s, e, d);
u(i * 2 + 1, mid + 1, r, s, e, d);
}
void init(int i, int l, int r) {
tr[i] = ID;
if (l != r) {
int mid = (l + r) / 2;
init(i * 2, l, mid);
init(i * 2 + 1, mid + 1, r);
}
}
void output(int i, int l, int r, vector<Restrict> &out) {
if (l == r) {
out.pb(tr[i]);
} else {
if (!(tr[i] == ID)) {
tr[i * 2] += tr[i];
tr[i * 2 + 1] += tr[i];
}
int mid = (l + r) / 2;
output(i * 2, l, mid, out);
output(i * 2 + 1, mid + 1, r, out);
}
}
} segTr;
int N;
void buildWall(int n, int k, int op[], int left[], int right[],
int height[], int finalHeight[]) {
N = n;
int Q = k;
segTr.init(1, 1, N);
for (int i = 0; i < Q; i++) {
if (op[i] == 1) {
segTr.u(1, 1, N, left[i] + 1, right[i] + 1, {height[i], (int) 1e9});
} else {
segTr.u(1, 1, N, left[i] + 1, right[i] + 1, {(int) -1e9, height[i]});
}
}
vector<Restrict> restrictions;
segTr.output(1, 1, N, restrictions);
for (int i = 0; i < N; i++) {
Restrict final = {0, 0};
final += restrictions[i];
// ps(restrictions[i].l);
// ps(restrictions[i].u);
assert(final.l == final.u);
finalHeight[i] = final.l;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
9 ms |
1016 KB |
Output is correct |
5 |
Correct |
7 ms |
1020 KB |
Output is correct |
6 |
Correct |
7 ms |
1060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
175 ms |
13984 KB |
Output is correct |
3 |
Correct |
237 ms |
8312 KB |
Output is correct |
4 |
Correct |
596 ms |
21272 KB |
Output is correct |
5 |
Correct |
288 ms |
21740 KB |
Output is correct |
6 |
Correct |
275 ms |
20220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
492 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
10 ms |
1060 KB |
Output is correct |
5 |
Correct |
7 ms |
1016 KB |
Output is correct |
6 |
Correct |
7 ms |
1016 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
179 ms |
14072 KB |
Output is correct |
9 |
Correct |
238 ms |
8424 KB |
Output is correct |
10 |
Correct |
600 ms |
21248 KB |
Output is correct |
11 |
Correct |
290 ms |
21724 KB |
Output is correct |
12 |
Correct |
302 ms |
20076 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
180 ms |
14072 KB |
Output is correct |
15 |
Correct |
43 ms |
2296 KB |
Output is correct |
16 |
Correct |
795 ms |
21100 KB |
Output is correct |
17 |
Correct |
284 ms |
20712 KB |
Output is correct |
18 |
Correct |
284 ms |
20704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
1 ms |
376 KB |
Output is correct |
4 |
Correct |
10 ms |
1016 KB |
Output is correct |
5 |
Correct |
7 ms |
1060 KB |
Output is correct |
6 |
Correct |
7 ms |
1016 KB |
Output is correct |
7 |
Correct |
2 ms |
380 KB |
Output is correct |
8 |
Correct |
175 ms |
14040 KB |
Output is correct |
9 |
Correct |
237 ms |
8440 KB |
Output is correct |
10 |
Correct |
582 ms |
21208 KB |
Output is correct |
11 |
Correct |
286 ms |
21628 KB |
Output is correct |
12 |
Correct |
273 ms |
20076 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
178 ms |
13944 KB |
Output is correct |
15 |
Correct |
43 ms |
2424 KB |
Output is correct |
16 |
Correct |
767 ms |
21120 KB |
Output is correct |
17 |
Correct |
286 ms |
20588 KB |
Output is correct |
18 |
Correct |
284 ms |
20588 KB |
Output is correct |
19 |
Correct |
688 ms |
75076 KB |
Output is correct |
20 |
Correct |
695 ms |
75072 KB |
Output is correct |
21 |
Correct |
684 ms |
75172 KB |
Output is correct |
22 |
Correct |
681 ms |
75116 KB |
Output is correct |
23 |
Correct |
672 ms |
75072 KB |
Output is correct |
24 |
Correct |
725 ms |
75204 KB |
Output is correct |
25 |
Correct |
669 ms |
75028 KB |
Output is correct |
26 |
Correct |
681 ms |
75216 KB |
Output is correct |
27 |
Correct |
688 ms |
75108 KB |
Output is correct |
28 |
Correct |
671 ms |
75072 KB |
Output is correct |
29 |
Correct |
669 ms |
75128 KB |
Output is correct |
30 |
Correct |
678 ms |
75172 KB |
Output is correct |