답안 #232728

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
232728 2020-05-18T01:08:21 Z medk 함박 스테이크 (JOI20_hamburg) C++14
15 / 100
178 ms 18784 KB
#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define x first
#define y second
#define sz(u) (int)(u.size())
#define all(u) u.begin(),u.end()

using namespace std;

const int MAXN=2e5;

struct rect
{
    int U,D,L,R;
};

vector<pair<int,int>> solveK1(vector<rect> v)
{
    int H[2]={1,(int)1e9},V[2]={1,(int)1e9};
    for(rect tmp:v)
    {
        H[0]=max(H[0],tmp.L);
        H[1]=min(H[1],tmp.R);
        V[0]=max(V[0],tmp.D);
        V[1]=min(V[1],tmp.U);
    }
    if(H[0]<=H[1] && V[0]<=V[1]) return  {{H[0],V[0]}};
    else return {};
}

vector<pair<int,int>> solveK2(vector<rect> v)
{
    int H[2]={1,(int)1e9},V[2]={1,(int)1e9};
    for(rect tmp:v)
    {
        H[0]=max(H[0],tmp.L);
        H[1]=min(H[1],tmp.R);
        V[0]=max(V[0],tmp.D);
        V[1]=min(V[1],tmp.U);
    }
    for(int x:{0,1})
        for(int y:{0,1})
        {
            vector<rect> tosend;
            for(rect tmp:v)
            {
                if(H[x]>=tmp.L && H[x]<=tmp.R && V[y]>=tmp.D && V[y]<=tmp.U) continue;
                tosend.pb(tmp);
            }
            vector<pair<int,int>> get=solveK1(tosend);
            if(sz(get)==0) continue;
            return {{H[x],V[y]},get[0]};
        }
    return {};
}


vector<pair<int,int>> solveK3(vector<rect> v)
{
    int H[2]={1,(int)1e9},V[2]={1,(int)1e9};
    for(rect tmp:v)
    {
        H[0]=max(H[0],tmp.L);
        H[1]=min(H[1],tmp.R);
        V[0]=max(V[0],tmp.D);
        V[1]=min(V[1],tmp.U);
    }
    for(int x:{0,1})
        for(int y:{0,1})
        {
            vector<rect> tosend;
            for(rect tmp:v)
            {
                if(H[x]>=tmp.L && H[x]<=tmp.R && V[y]>=tmp.D && V[y]<=tmp.U) continue;
                tosend.pb(tmp);
            }
            vector<pair<int,int>> get=solveK2(tosend);
            if(sz(get)==0) continue;
            return {{H[x],V[y]},get[0],get[1]};
        }
    return {};
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n,k; cin>>n>>k;
    vector<rect> v;
    rect tmp;
    for(int i=0;i<n;i++)
    {
        cin>>tmp.L>>tmp.D>>tmp.R>>tmp.U;
        v.pb(tmp);
    }
    vector<pair<int,int>> ans;
    if(k==1) ans=solveK1(v);
    if(k==2) ans=solveK2(v);
    if(k==3) ans=solveK3(v);
    for(pair<int,int> pt:ans) cout<<pt.x<<' '<<pt.y<<'\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 99 ms 6752 KB Output is correct
6 Correct 107 ms 6764 KB Output is correct
7 Correct 101 ms 6844 KB Output is correct
8 Correct 105 ms 6752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 99 ms 10232 KB Output is correct
6 Correct 110 ms 10464 KB Output is correct
7 Correct 104 ms 10040 KB Output is correct
8 Correct 111 ms 12748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 109 ms 11748 KB Output is correct
14 Correct 102 ms 11872 KB Output is correct
15 Correct 105 ms 12356 KB Output is correct
16 Correct 102 ms 10080 KB Output is correct
17 Correct 110 ms 10848 KB Output is correct
18 Correct 98 ms 8932 KB Output is correct
19 Correct 104 ms 12772 KB Output is correct
20 Correct 178 ms 18784 KB Output is correct
21 Correct 110 ms 12768 KB Output is correct
22 Correct 121 ms 17944 KB Output is correct
23 Correct 155 ms 17760 KB Output is correct
24 Correct 133 ms 17248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -