Submission #559913

# Submission time Handle Problem Language Result Execution time Memory
559913 2022-05-11T00:50:50 Z Yazan_Alattar Izvanzemaljci (COI21_izvanzemaljci) C++14
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 100007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const double eps = 1e-6;
const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0};
const int block = 320;

struct Point{
    ll x, y;

    void read(){
        cin >> x >> y;
        return;
    }
} p[M];

bool OnX (Point a, Point b){
    if(a.x == b.x) return a.y < b.y;
    return a.x < b.x;
}

bool OnY (Point a, Point b){
    if(a.y == b.y) return a.x < b.y;
    return a.y < b.y;
}

ll n, k, mx[M], my[M], mnx[M], mny[M];

void init(){
    mnx[0] = mny[0] = inf;
    for(int i = 1; i <= n; ++i){
        mnx[i] = min(mnx[i - 1], p[i].x);
        mx[i] = max(mx[i - 1], p[i].x);

        mny[i] = min(mny[i - 1], p[i].y);
        my[i] = max(my[i - 1], p[i].y);
    }
    return;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; ++i) p[i].read();

    if(k == 1) init(), cout << mnx[n] << " " << mny[n] << " " << max(mx[n] - mnx[n], my[n] - mny[n]) << endl;

    else if(k == 2){
        ll ans = inf; vector < pair < pair <ll,ll>, ll > > v;
        sort(p + 1, p + n + 1, OnX);
        init();
        ll a = inf, b = 0, c = inf, d = 0;
        for(int i = n; i; --i){
            if(i < n){
                ll x = max((mx[i] - mnx[i], my[i] - mny[i]) * max(mx[i] - mnx[i], my[i] - mny[i]), max(b - a, d - c) * max(b - a, d - c));

                if(x < ans){
                    ans = x;
                    v.clear();

                    v.pb({{mnx[i], mny[i]}, max(mx[i] - mnx[i], my[i] - mny[i])});
                    v.pb({{a, c}, max(d - c, b - a)});
                }

            }

            a = min(a, p[i].x);
            b = max(b, p[i].x);

            c = min(c, p[i].y);
            d = max(d, p[i].y);
        }

        sort(p + 1, p + n + 1, OnY);
        init();
        a = inf; b = 0; c = inf; d = 0;
        for(int i = n; i; --i){
            if(i < n){
                ll x = max((mx[i] - mnx[i], my[i] - mny[i]) * max(mx[i] - mnx[i], my[i] - mny[i]), max(b - a, d - c) * max(b - a, d - c));

                if(x < ans){
                    ans = x;
                    v.clear();

                    v.pb({{mnx[i], mny[i]}, max(mx[i] - mnx[i], my[i] - mny[i])});
                    v.pb({{a, c}, max(d - c, b - a)});
                }

            }

            a = min(a, p[i].x);
            b = max(b, p[i].x);

            c = min(c, p[i].y);
            d = max(d, p[i].y);
        }

        for(auto i : v) cout << i.F.F << " " << i.F.S << " " << i.S << endl;
    }
    return 0;
}

Compilation message

izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:65:35: warning: left operand of comma operator has no effect [-Wunused-value]
   65 |                 ll x = max((mx[i] - mnx[i], my[i] - mny[i]) * max(mx[i] - mnx[i], my[i] - mny[i]), max(b - a, d - c) * max(b - a, d - c));
      |                             ~~~~~~^~~~~~~~
izvanzemaljci.cpp:89:35: warning: left operand of comma operator has no effect [-Wunused-value]
   89 |                 ll x = max((mx[i] - mnx[i], my[i] - mny[i]) * max(mx[i] - mnx[i], my[i] - mny[i]), max(b - a, d - c) * max(b - a, d - c));
      |                             ~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -