Submission #384288

# Submission time Handle Problem Language Result Execution time Memory
384288 2021-04-01T08:46:17 Z fammo ČVENK (COI15_cvenk) C++11
0 / 100
3000 ms 3820 KB
#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];
        }

        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 time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3087 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3017 ms 2540 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3076 ms 3820 KB Time limit exceeded
2 Halted 0 ms 0 KB -