답안 #420823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
420823 2021-06-08T14:07:35 Z JvThunder Izvanzemaljci (COI21_izvanzemaljci) C++14
5 / 100
3000 ms 1484 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
typedef long long ll;

using namespace std;

int n,k;

struct Node
{
    int x = 1,y = 1,l = 1;
};

bool overlap(Node a,Node b)
{
    if(a.x+a.l<=b.x) return false;
    if(b.x+b.l<=a.x) return false;
    if(a.y+a.l<=b.y) return false;
    if(b.y+b.l<=a.y) return false;
    return true;
}

pair<pair<Node,Node>,Node> ans;
int mnl = 1e9+7;

vector<pair<int,int>> v;
vector<pair<int,int>> g[3];
void compute()
{
    Node a[3];
    for(int i=0;i<3;i++)
    {
        if(g[i].size()==0) return;
        int mnx = 1;
        int mxx = 1;
        int mny = 1;
        int mxy = 1;

        bool isfir = true;
        for(auto c:g[i])
        {
            int x = c.fir;
            int y = c.sec;
            if(isfir)
            {
                isfir = false;
                mnx = mxx = x;
                mny = mxy = y;
            }
            else
            {
                mnx = min(mnx,x);
                mxx = max(mxx,x);
                mny = min(mny,y);
                mxy = max(mxy,y);
            }
        }
        a[i].x = mnx; a[i].y = mny; a[i].l = max(max(mxx-mnx,mxy-mny),1);
    }
    if(overlap(a[0],a[1]) || overlap(a[2],a[1]) || overlap(a[0],a[2])) return;
    if(max(max(a[0].l,a[1].l),a[2].l) <= mnl)
    {
        mnl = max(max(a[0].l,a[1].l),a[2].l);
        ans = {{a[0],a[1]},a[2]};
        return;
    }
}

void bf(int curr)
{
    if(curr==n) 
    {
        compute();
        return;
    }
    for(int i=0;i<3;i++)
    {
        g[i].push_back(v[curr]);
        bf(curr+1);
        g[i].pop_back();
    }
}

void solve()
{
    cin >> n >> k;
    int mnx = 0;
    int mxx = 0;
    int mny = 0;
    int mxy = 0;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin >> x >> y;
        if(i==0)
        {
            mnx = mxx = x;
            mny = mxy = y;
        }
        else
        {
            mnx = min(mnx,x);
            mxx = max(mxx,x);
            mny = min(mny,y);
            mxy = max(mxy,y);
        }
        v.pb({x,y});
    }

    if(k==1) 
    {
        cout << mnx << " " << mny << " " << max(max(mxx-mnx,mxy-mny),1) << endl;
        return;
    }

    bf(0);
    cout << ans.fir.fir.x << " " << ans.fir.fir.y << " " << ans.fir.fir.l << endl;
    cout << ans.fir.sec.x << " " << ans.fir.sec.y << " " << ans.fir.sec.l << endl;
    cout << ans.sec.x << " " << ans.sec.y << " " << ans.sec.l << endl;
	return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	solve();
 	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 28 ms 1484 KB Output is correct
8 Correct 38 ms 1348 KB Output is correct
9 Correct 27 ms 1484 KB Output is correct
10 Correct 27 ms 1428 KB Output is correct
11 Correct 33 ms 1436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3070 ms 332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3094 ms 332 KB Time limit exceeded
2 Halted 0 ms 0 KB -