Submission #264735

# Submission time Handle Problem Language Result Execution time Memory
264735 2020-08-14T08:43:09 Z super_j6 Krave (COI14_krave) C++14
100 / 100
1146 ms 135120 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 97 ms 69368 KB Output is correct
2 Correct 80 ms 69216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 90 ms 69624 KB Output is correct
2 Correct 94 ms 70132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 314 ms 74872 KB Output is correct
2 Correct 359 ms 100984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 316 ms 74924 KB Output is correct
2 Correct 373 ms 101880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 290 ms 74832 KB Output is correct
2 Correct 462 ms 110076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 449 ms 83448 KB Output is correct
2 Correct 468 ms 115960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1106 ms 98720 KB Output is correct
2 Correct 524 ms 122616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1074 ms 97656 KB Output is correct
2 Correct 403 ms 107512 KB Output is correct
3 Correct 395 ms 105080 KB Output is correct
4 Correct 545 ms 125560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1146 ms 98936 KB Output is correct
2 Correct 445 ms 111736 KB Output is correct
3 Correct 312 ms 77116 KB Output is correct
4 Correct 682 ms 132280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1146 ms 99048 KB Output is correct
2 Correct 362 ms 101584 KB Output is correct
3 Correct 262 ms 77304 KB Output is correct
4 Correct 618 ms 135120 KB Output is correct