Submission #384290

#TimeUsernameProblemLanguageResultExecution timeMemory
384290fammoČVENK (COI15_cvenk)C++11
0 / 100
3097 ms1900 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef long double ld; #define X first #define Y second #define pb push_back #define fastio ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr); #define rndom mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) #define endl '\n' #define int long long const int N = 300 * 1000 + 20, L = 30; int n, x[N], y[N], ans; int check(int mx, int my, int i){ if(x[i] < mx){ if(y[i] < my) return 0; else return 1; }else{ if(y[i] < my) return 2; else return 3; } } void bt(int lx, int rx, int ly, int ry){ int mx = (lx + rx)/2, my = (ly+ry)/2; if(max(x[0], x[1]) < mx && max(y[0], y[1]) < my){ bt(lx, mx, ly, my); } else if(max(x[0], x[1]) < mx && min(y[0], y[1]) >= my){ bt(lx, mx, my, ry); } else if(min(x[0], x[1]) >= mx && max(y[0], y[1]) < my){ bt(mx, rx, ly, my); } else{ // cout << "LX:" << lx << " RX:" << rx << " LY:" << ly << " RY:" << ry << endl; int a = check(mx,my,0),b=check(mx,my,1); if((a == 1 && b == 2) ||( a == 2 && b == 1))cout << x[0] + x[1] + y[0] + y[1] - 2*lx - 2*ly; else if(a == 2 || b == 2){ cout << abs(x[0]-x[1]) + y[0] + y[1]; }else{ cout << abs(y[0]-y[1]) + x[0] + x[1]; } cout << '\n'; exit(0); } } int32_t main(){ fastio; ///auto t = clock(); cin >> n; for(int i = 0; i < n; i ++){ cin >> x[i] >> y[i]; } if(n != 2)while(1)n++; bt(0, (1<<30), 0, (1<<30)); ///cout << clock() - t << "ms" << endl; 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...