Submission #264771

# Submission time Handle Problem Language Result Execution time Memory
264771 2020-08-14T09:20:35 Z super_j6 Krave (COI14_krave) C++14
100 / 100
1122 ms 133880 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
 
pi operator+(pi x, pi y){
	return {max(x.f, y.f), min(x.s, y.s)};
}
 
const int inf = 0x3f3f3f3f;
 
struct segTree{
	int l, r;
	segTree *left, *right;
	set<int> s;
	
	segTree(int a, int b){
		l = a, r = b;
		s.insert(-inf);
		s.insert(inf);
		if(l != r){
			int mid = (l + r) / 2;
			left = new segTree(l, mid);
			right = new segTree(mid + 1, r);
		}
	}
	
	pi amt(int x){
		auto it = s.lower_bound(x);
		return {*it == x ? x :*prev(it), *it}; 
	}
	
	void add(int a, int b, int v){
		if(b < l || r < a) return;
		if(a <= l && r <= b){
			s.insert(v);
			return;
		}
		left->add(a, b, v);
		right->add(a, b, v);
	}
	
	pi qry(int x, int y){
		if(x < l || r < x) return {-inf, inf};
		if(l == r) return amt(y);
		return left->qry(x, y) + amt(y) + right->qry(x, y);
	}
};
 
const int mxn = 100000;
int n, m, q;
segTree tx(0, mxn), ty(0, mxn);
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m >> q;
	
	for(int i = 0; i < 2; i++){
		tx.add(0, m, i * n);
		ty.add(0, n, i * m);
	}
	
	while(q--){
		ll t, x, y, r1, r2;
		cin >> x >> y >> t;
		pi a = tx.qry(y, x);
		pi b = ty.qry(x, y);
		if(!~-t){
			r1 = (a.s - a.f) * (y - b.f);
			r2 = (a.s - a.f) * (b.s - y);
			ty.add(a.f, a.s, y);
		}else{
			r1 = (x - a.f) * (b.s - b.f);
			r2 = (a.s - x) * (b.s - b.f);
			tx.add(b.f, b.s, x);
		}
		if(r1 > r2) swap(r1, r2);
		cout << r1 << " " << r2 << endl;
	}
 
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 80 ms 69368 KB Output is correct
2 Correct 87 ms 69272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 69624 KB Output is correct
2 Correct 88 ms 70008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 280 ms 74104 KB Output is correct
2 Correct 342 ms 100136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 286 ms 74232 KB Output is correct
2 Correct 380 ms 100600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 281 ms 74104 KB Output is correct
2 Correct 426 ms 108872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 455 ms 82936 KB Output is correct
2 Correct 479 ms 115064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1062 ms 97384 KB Output is correct
2 Correct 532 ms 121720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1122 ms 96572 KB Output is correct
2 Correct 406 ms 106872 KB Output is correct
3 Correct 401 ms 103672 KB Output is correct
4 Correct 589 ms 124408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1088 ms 97448 KB Output is correct
2 Correct 441 ms 110840 KB Output is correct
3 Correct 241 ms 75640 KB Output is correct
4 Correct 620 ms 130936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1076 ms 97736 KB Output is correct
2 Correct 355 ms 100984 KB Output is correct
3 Correct 246 ms 75772 KB Output is correct
4 Correct 680 ms 133880 KB Output is correct