답안 #230000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230000 2020-05-07T15:27:59 Z MarcoMeijer 함박 스테이크 (JOI20_hamburg) C++14
15 / 100
133 ms 3704 KB
#include <bits/stdc++.h>
using namespace std;

//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
#define sz size()

//===================//
//  Added libraries  //
//===================//

//===================//
//end added libraries//
//===================//

void program();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    program();
}


//===================//
//   begin program   //
//===================//

const int MX = 3e5;
int n, L[MX], R[MX], U[MX], D[MX];
bitset<MX> used;

void place(int x, int y) {
    RE(i,n) {
        if(L[i] <= x && x <= R[i] && U[i] <= y && y <= D[i]) used[i] = 1;
    }
}
bool solve(int k) {
    bitset<MX> curUsed = used;
    int maxL=0, minR=INF, maxU=0, minD=INF;
    RE(i,n) {
        if(used[i]) continue;
        maxL = max(maxL, L[i]);
        minR = min(minR, R[i]);
        maxU = max(maxU, U[i]);
        minD = min(minD, D[i]);
    }
    if(k == 1) {
        place(maxL, maxU);
        if(used.count() == n) {
            cout<<maxL<<" "<<maxU<<endl;
            return 1;
        }
        return 0;
    }
    if(k == 2) {
        place(minR, minD);
        if(solve(1)) {
            cout<<minR<<" "<<minD<<endl;
            return 1;
        }
        used = curUsed;
        place(minR, maxU);
        if(solve(1)) {
            cout<<minR<<" "<<maxU<<endl;
            return 1;
        }
        return 0;
    }
    if(k == 3) {
        place(minR, minD);
        if(solve(2)) {
            cout<<minR<<" "<<minD<<endl;
            return 1;
        }
        used = curUsed;
        place(minR, maxU);
        if(solve(2)) {
            cout<<minR<<" "<<maxU<<endl;
            return 1;
        }
        used = curUsed;
        place(maxL, minD);
        if(solve(2)) {
            cout<<maxL<<" "<<minD<<endl;
            return 1;
        }
        used = curUsed;
        place(maxL, maxU);
        if(solve(2)) {
            cout<<maxL<<" "<<maxU<<endl;
            return 1;
        }
        return 0;
    }
    if(k == 4) {
        RE(i,n) {
            if(minD <= U[i] && U[i] <= maxU) {
                place(minR, U[i]);
                if(solve(3)) {
                    cout<<minR<<" "<<U[i]<<endl;
                    return 1;
                }
                used = curUsed;
            }
            if(minD <= D[i] && D[i] <= maxU) {
                place(minR, D[i]);
                if(solve(3)) {
                    cout<<minR<<" "<<D[i]<<endl;
                    return 1;
                }
                used = curUsed;
            }
        }
        return 0;
    }
    return 0;
}

void program() {
    int k;
    cin>>n>>k;
    RE(i,n) cin>>L[i]>>U[i]>>R[i]>>D[i];
    used.reset();
    solve(k);
}

Compilation message

hamburg.cpp: In function 'bool solve(int)':
hamburg.cpp:65:25: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   65 |         if(used.count() == n) {
      |            ~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 1 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 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 512 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 91 ms 3576 KB Output is correct
6 Correct 97 ms 3576 KB Output is correct
7 Correct 121 ms 3576 KB Output is correct
8 Correct 92 ms 3576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 93 ms 3536 KB Output is correct
6 Correct 96 ms 3620 KB Output is correct
7 Correct 109 ms 3552 KB Output is correct
8 Correct 113 ms 3600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 1 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 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 128 ms 3580 KB Output is correct
14 Correct 101 ms 3664 KB Output is correct
15 Correct 93 ms 3576 KB Output is correct
16 Correct 115 ms 3704 KB Output is correct
17 Correct 97 ms 3628 KB Output is correct
18 Correct 116 ms 3576 KB Output is correct
19 Correct 102 ms 3576 KB Output is correct
20 Correct 99 ms 3576 KB Output is correct
21 Correct 133 ms 3704 KB Output is correct
22 Correct 115 ms 3576 KB Output is correct
23 Correct 108 ms 3576 KB Output is correct
24 Correct 131 ms 3648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 512 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -