# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
168466 |
2019-12-13T08:16:43 Z |
Fischer |
Krave (COI14_krave) |
C++14 |
|
1306 ms |
103884 KB |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
set<int> st[2][maxn<<2];
void add_st(int t, int ll, int rr, int p, int nx=1, int l=0, int r=1e5) {
if (rr < l or r < ll) return;
if (ll <= l and r <= rr) {
st[t][nx].insert(p);
return;
}
int mid = (l+r)/2;
add_st(t, ll, rr, p, nx<<1, l, mid);
add_st(t, ll, rr, p, nx<<1|1, mid+1, r);
}
const int INF = 1e8;
pair<int, int> nil = {0, INF};
pair<int, int> query(int t, int pos, int v, int nx=1, int l=0, int r=1e5) {
if (pos < l or r < pos) return nil;
pair<int, int> L = nil, R = nil, M = nil;
if (l != r) {
int mid = (l + r) / 2;
L = query(t, pos, v, nx<<1, l, mid);
R = query(t, pos, v, nx<<1|1, mid+1, r);
}
if (not st[t][nx].empty()) {
auto q = st[t][nx].lower_bound(v);
if (q == st[t][nx].end()) --q;
if (*q > v) {
M.second = *q;
} else {
M.first = *q;
}
if (q != st[t][nx].begin()) --q;
if (*q < v) {
M.first = max(M.first, *q);
}
}
return {max({L.first, M.first, R.first}),
min({L.second, M.second, R.second})};
}
int main() {
int A, B, N;
cin >> A >> B >> N;
add_st(0, 0, A, 0);
add_st(0, 0, A, B);
add_st(1, 0, B, 0);
add_st(1, 0, B, A);
for (int i = 1; i <= N; ++i) {
int x, y, d;
cin >> x >> y >> d;
pair<int, int> P = query(0, x, y);
pair<int, int> Q = query(1, y, x);
long long a1, a2;
if (d == 1) {
a1 = (y - P.first) *1ll* (Q.second - Q.first);
a2 = (P.second - y) *1ll* (Q.second - Q.first);
add_st(0, Q.first, Q.second, y);
} else {
a1 = (P.second - P.first) *1ll* (x - Q.first);
a2 = (P.second - P.first) *1ll* (Q.second - x);
add_st(1, P.first, P.second, x);
}
if (a1 > a2) swap(a1, a2);
cout << a1 << " " << a2 << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
38008 KB |
Output is correct |
2 |
Correct |
37 ms |
38012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
38264 KB |
Output is correct |
2 |
Correct |
47 ms |
38776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
365 ms |
42904 KB |
Output is correct |
2 |
Correct |
676 ms |
69752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
402 ms |
42864 KB |
Output is correct |
2 |
Correct |
732 ms |
70620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
374 ms |
42796 KB |
Output is correct |
2 |
Correct |
821 ms |
78860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
624 ms |
51564 KB |
Output is correct |
2 |
Correct |
878 ms |
84728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1262 ms |
65992 KB |
Output is correct |
2 |
Correct |
1004 ms |
91356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1288 ms |
65080 KB |
Output is correct |
2 |
Correct |
620 ms |
76284 KB |
Output is correct |
3 |
Correct |
808 ms |
73836 KB |
Output is correct |
4 |
Correct |
1036 ms |
94464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1263 ms |
66180 KB |
Output is correct |
2 |
Correct |
688 ms |
80332 KB |
Output is correct |
3 |
Correct |
565 ms |
45824 KB |
Output is correct |
4 |
Correct |
1138 ms |
100980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1306 ms |
66404 KB |
Output is correct |
2 |
Correct |
542 ms |
70264 KB |
Output is correct |
3 |
Correct |
555 ms |
45784 KB |
Output is correct |
4 |
Correct |
1247 ms |
103884 KB |
Output is correct |