Submission #90600

#TimeUsernameProblemLanguageResultExecution timeMemory
90600jasony123123Krave (COI14_krave)C++11
100 / 100
1134 ms164324 KiB
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> //#include <ext/pb_ds/tree_policy.hpp> //#include <ext/pb_ds/assoc_container.hpp> using namespace std; //using namespace __gnu_pbds; #define FOR(i,start,end) for(int i=start;i<(int)(end);i++) #define FORE(i,start,end) for(int i=start;i<=(int)end;i++) #define RFOR(i,start,end) for(int i = start; i>end; i--) #define RFORE(i,start,end) for(int i = start; i>=end; i--) #define all(a) a.begin(), a.end() #define mt make_tuple #define mp make_pair #define v vector #define sf scanf #define pf printf #define dvar(x) cout << #x << " := " << x << "\n" #define darr(x,n) FOR(i,0,n) cout << #x << "[" << i << "]" << " := " << x[i] << "\n" typedef long long ll; typedef long double ld; typedef pair<int, int > pii; typedef pair<ll, ll> pll; //template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<class T> void minn(T &a, T b) { a = min(a, b); } template<class T> void maxx(T &a, T b) { a = max(a, b); } void io() { #ifdef LOCAL_PROJECT freopen("input.in", "r", stdin); freopen("output.out", "w", stdout); #else /* online submission */ #endif ios_base::sync_with_stdio(false); cin.tie(NULL); } const ll MOD = 1000000007LL; const ll PRIME = 105943LL; const int INF = 1e8; /****************************************************************/ template <int K> struct SegmentTree { static const int SZ = 1 << K; set<int> data[SZ << 1]; void init(int lb, int ub) { FOR(i, 1, 2 * SZ) data[i].insert(lb), data[i].insert(ub); } pii query(int pos, int x) { // query in pos bounds for x pos += SZ; int lo = -INF, hi = INF; while (pos) { auto it = data[pos].upper_bound(x); minn(hi, *it); it--; maxx(lo, *it); pos /= 2; } return{ lo, hi }; } void add(int x, int a, int b) { // add x to [a,b] update(1, 0, SZ - 1, a, b, x); } void update(int node, int l, int r, int a, int b, int x) { if (l > b || r < a) return; if (l >= a && r <= b) { data[node].insert(x); return; } int mid = (l + r) / 2; update(node * 2, l, mid, a, b, x); update(node * 2 + 1, mid + 1, r, a, b, x); } }; SegmentTree<17> htree, vtree; void test() { htree.init(0, 10); htree.add(6, 1, 3); htree.add(2, 1, 4); cout << htree.query(2, 3).first << " " << htree.query(2, 3).second << "\n"; cout << htree.query(0, 6).first << " " << htree.query(0, 6).second << "\n"; htree.add(8, 0, 2); cout << htree.query(1, 1).first << " " << htree.query(1, 1).second << "\n"; cout << htree.query(3, 9).first << " " << htree.query(3, 9).second << "\n"; } int main() { io(); // test(); int a, b; cin >> a >> b; htree.init(0, b); vtree.init(0, a); int n; cin >> n; FOR(i, 0, n) { int x, y, d; cin >> x >> y >> d; pll yb = htree.query(x, y); // {ymin, ymax} pll xb = vtree.query(y, x); // {xmin, xmax} pll area; if (d == 1) { // build horizontal area = { (xb.second - xb.first)*(y - yb.first), (xb.second - xb.first)*(yb.second - y) }; htree.add(y, xb.first, xb.second); } else { // build vertical area = { (yb.second - yb.first)*(x - xb.first), (yb.second - yb.first)*(xb.second - x) }; vtree.add(x, yb.first, yb.second); } if (area.first > area.second) swap(area.first, area.second); cout << area.first << " " << area.second << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...