# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
308344 |
2020-10-01T00:51:01 Z |
caoash |
Krave (COI14_krave) |
C++14 |
|
5000 ms |
56476 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
const int MX = 100005;
const int MOD = (int) (1e9 + 7);
const ll INF = (ll) 1e18;
namespace output {
void pr(int x) {
cout << x;
}
void pr(long x) {
cout << x;
}
void pr(ll x) {
cout << x;
}
void pr(unsigned x) {
cout << x;
}
void pr(unsigned long x) {
cout << x;
}
void pr(unsigned long long x) {
cout << x;
}
void pr(float x) {
cout << x;
}
void pr(double x) {
cout << x;
}
void pr(long double x) {
cout << x;
}
void pr(char x) {
cout << x;
}
void pr(const char * x) {
cout << x;
}
void pr(const string & x) {
cout << x;
}
void pr(bool x) {
pr(x ? "true" : "false");
}
template < class T1, class T2 > void pr(const pair < T1, T2 > & x);
template < class T > void pr(const T & x);
template < class T, class...Ts > void pr(const T & t,
const Ts & ...ts) {
pr(t);
pr(ts...);
}
template < class T1, class T2 > void pr(const pair < T1, T2 > & x) {
pr("{", x.f, ", ", x.s, "}");
}
template < class T > void pr(const T & x) {
pr("{"); // const iterator needed for vector<bool>
bool fst = 1;
for (const auto & a: x) pr(!fst ? ", " : "", a), fst = 0;
pr("}");
}
void ps() {
pr("\n");
} // print w/ spaces
template < class T, class...Ts > void ps(const T & t,
const Ts & ...ts) {
pr(t);
if (sizeof...(ts)) pr(" ");
ps(ts...);
}
void pc() {
cout << "]" << endl;
} // debug w/ commas
template < class T, class...Ts > void pc(const T & t,
const Ts & ...ts) {
pr(t);
if (sizeof...(ts)) pr(", ");
pc(ts...);
}
#define dbg(x...) pr("[", #x, "] = ["), pc(x);
}
#ifdef LOCAL
using namespace output;
#endif
set<int> htree[4 * MX], vtree[4 * MX];
int A, B;
void update(int v, int l, int r, int ul, int ur, int x, int t) {
if (ul > r || ur < l) {
return;
} else if(l >= ul && r <= ur) {
if (!t) {
htree[v].insert(x);
} else {
vtree[v].insert(x);
}
return;
} else {
int m = (l + r) / 2;
update(2 * v + 1, l, m, ul, ur, x, t);
update(2 * v + 2, m + 1, r, ul, ur, x, t);
return;
}
}
void query(int v, int l, int r, int qi, int t, set<int> &curr) {
if (!t) {
for (auto &x : htree[v]) curr.insert(x);
} else {
for (auto &x : vtree[v]) curr.insert(x);
}
if (l == r) {
return;
} else {
int m = (l + r) / 2;
if (m >= qi) {
query(2 * v + 1, l, m, qi, t, curr);
} else {
query(2 * v + 2, m + 1, r, qi, t, curr);
}
return;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin >> A >> B;
update(0, 0, A, 0, A, 0, 0);
update(0, 0, A, 0, A, B, 0);
update(0, 0, B, 0, B, 0, 1);
update(0, 0, B, 0, B, A, 1);
int n; cin >> n;
for (int i = 0; i < n; i++) {
int x, y, d; cin >> x >> y >> d;
d--;
array<int, 4> cans;
set<int> ud, lr;
query(0, 0, A, x, 0, ud);
query(0, 0, B, y, 1, lr);
// dbg(ud, lr);
cans[0] = *ud.lower_bound(y), cans[1] = *(--ud.lower_bound(y));
cans[2] = *lr.lower_bound(x), cans[3] = *(--lr.lower_bound(x));
// dbg(cans);
ll area = 0;
ll area2 = 0;
if (!d) {
area = (cans[0] - y) * (cans[2] - cans[3]);
area2 = (y - cans[1]) * (cans[2] - cans[3]);
update(0, 0, A, cans[3], cans[2], y, 0);
}
else {
area = (cans[2] - x) * (cans[0] - cans[1]);
area2 = (x - cans[3]) * (cans[0] - cans[1]);
update(0, 0, B, cans[1], cans[0], x, 1);
}
if (area > area2) swap(area, area2);
cout << area << " " << area2 << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
38016 KB |
Output is correct |
2 |
Correct |
27 ms |
37888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
38264 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5062 ms |
39040 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5084 ms |
39012 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5093 ms |
38904 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5059 ms |
51188 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5017 ms |
53220 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5036 ms |
54680 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5050 ms |
53240 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5047 ms |
56476 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |