Submission #125341

#TimeUsernameProblemLanguageResultExecution timeMemory
125341abacabaKrave (COI14_krave)C++14
5 / 100
809 ms262148 KiB
#include <bits/stdc++.h> using namespace std; #define max3(a, b, c) max(a, max(b, c)) #define min3(a, b, c) min(a, min(b, c)) #define mp make_pair #define f first #define se second #define pb push_back #define ppb pop_back #define ll long long #define ull unsigned long long #define cntbit(x) __builtin_popcount(x) #define uset unordered_set #define endl '\n' #define umap unordered_map #define pii pair<int, int> #define ld long double #define pll pair<long long, long long> const int N = 1e5 + 15; int w, h, n, m, k; vector <int> add[2][N << 2]; set <int> t[2][N << 2]; inline void push(int v, int isx) { while(!add[isx][v].empty()) { if(v < (N << 1)) { add[isx][v << 1].pb(add[isx][v].back()); add[isx][v << 1 | 1].pb(add[isx][v].back()); t[isx][v << 1].insert(add[isx][v].back()); t[isx][v << 1 | 1].insert(add[isx][v].back()); } add[isx][v].ppb(); } } void multiupdate(int v, int tl, int tr, int l, int r, int val, int isx) { if(tl > r || tr < l || l > r) return; push(v, isx); if(tl >= l && tr <= r) { t[isx][v].insert(val); add[isx][v].pb(val); return; } int mid = tl + tr >> 1; multiupdate(v << 1, tl, mid, l, r, val, isx); multiupdate(v << 1 | 1, mid + 1, tr, l, r, val, isx); } pii get(int v, int tl, int tr, int pos, int x, int isx) { push(v, isx); if(tl == tr) return mp(*(--t[isx][v].upper_bound(x)), *t[isx][v].upper_bound(x)); int mid = tl + tr >> 1; if(pos <= mid) return get(v << 1, tl, mid, pos, x, isx); return get(v << 1 | 1, mid + 1, tr, pos, x, isx); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> w >> h >> n; multiupdate(1, 1, h, 1, h, 0, 0); multiupdate(1, 1, h, 1, h, w, 0); multiupdate(1, 1, w, 1, w, 0, 1); multiupdate(1, 1, w, 1, w, h, 1); for(int i = 1; i <= n; ++i) { int x, y, d; cin >> x >> y >> d; if(d == 1) { pii x12 = get(1, 1, h, y, x, 0); pii y12 = get(1, 1, w, x, y, 1); ll area1 = (ll)abs(y - y12.f) * abs(x12.f - x12.se); ll area2 = (ll)abs(y - y12.se) * abs(x12.f - x12.se); if(area2 < area1) swap(area2, area1); cout << area1 << ' ' << area2 << endl; multiupdate(1, 1, w, x12.f, x12.se, y, 1); } else { pii x12 = get(1, 1, h, y, x, 0); pii y12 = get(1, 1, w, x, y, 1); ll area1 = (ll)abs(y12.se - y12.f) * abs(x - x12.se); ll area2 = (ll)abs(y12.se - y12.f) * abs(x12.f - x); if(area2 < area1) swap(area2, area1); cout << area1 << ' ' << area2 << endl; multiupdate(1, 1, h, y12.f, y12.se, x, 0); } } return 0; }

Compilation message (stderr)

krave.cpp: In function 'void multiupdate(int, int, int, int, int, int, int)':
krave.cpp:48:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid = tl + tr >> 1;
            ~~~^~~~
krave.cpp: In function 'std::pair<int, int> get(int, int, int, int, int, int)':
krave.cpp:57:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid = tl + tr >> 1;
            ~~~^~~~
#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...