Submission #559917

# Submission time Handle Problem Language Result Execution time Memory
559917 2022-05-11T00:57:38 Z Yazan_Alattar Izvanzemaljci (COI21_izvanzemaljci) C++14
5 / 100
34 ms 7016 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 = 2e9;
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;
    mx[0] = my[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(1ll, 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 = -inf, c = inf, d = -inf;
        for(int i = n; i; --i){
            if(i < n && mnx[i] != a){
                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 = -inf; c = inf; d = -inf;
        for(int i = n; i; --i){
            if(i < n && mny[i] != c){
                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 << " " << max(i.S, 1ll) << endl;
    }
    return 0;
}

Compilation message

izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:68:35: warning: left operand of comma operator has no effect [-Wunused-value]
   68 |                 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:92:35: warning: left operand of comma operator has no effect [-Wunused-value]
   92 |                 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 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 23 ms 6988 KB Output is correct
8 Correct 23 ms 6988 KB Output is correct
9 Correct 24 ms 7004 KB Output is correct
10 Correct 24 ms 7016 KB Output is correct
11 Correct 34 ms 6988 KB Output is correct
# 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 -