답안 #559920

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
559920 2022-05-11T01:00:00 Z Yazan_Alattar Izvanzemaljci (COI21_izvanzemaljci) C++14
5 / 100
27 ms 5312 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){
        if(n == 1){
            cout << p[1].x << " " << p[1].y << " " << 1 << endl;
            cout << inf << " " << inf << " " << 1 << endl;
            return 0;
        }

        ll ans = 1e18; 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:74:35: warning: left operand of comma operator has no effect [-Wunused-value]
   74 |                 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:98:35: warning: left operand of comma operator has no effect [-Wunused-value]
   98 |                 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));
      |                             ~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 27 ms 5264 KB Output is correct
8 Correct 27 ms 5312 KB Output is correct
9 Correct 24 ms 5272 KB Output is correct
10 Correct 24 ms 5308 KB Output is correct
11 Correct 23 ms 5280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 0 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 324 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -