Submission #289894

# Submission time Handle Problem Language Result Execution time Memory
289894 2020-09-03T08:05:12 Z 반딧불(#5785) Hamburg Steak (JOI20_hamburg) C++17
6 / 100
158 ms 3576 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, k;
int l[200002], dd[200002], r[200002], u[200002];
int xMin = 0, xMax = 1e9, yMin = 0, yMax = 1e9;

int main(){
    scanf("%d %d", &n, &k);
    for(int i=1; i<=n; i++){
        scanf("%d %d %d %d", &l[i], &dd[i], &r[i], &u[i]);
        xMin = max(xMin, l[i]);
        xMax = min(xMax, r[i]);
        yMin = max(yMin, dd[i]);
        yMax = min(yMax, u[i]);
    }
    if(k==1) printf("%d %d", xMin, yMin);
    else{
        vector<pair<int, int> > v {make_pair(xMin, yMin), make_pair(xMin, yMax), make_pair(xMax, yMin), make_pair(xMax, yMax)};

        for(int d=0; d<16; d++){
            if(__builtin_popcount(d) > k) continue;
            int sum = 0;
            for(int i=1; i<=n; i++){
                for(int j=0; j<4; j++){
                    if(!(d&(1<<j))) continue;
                    if(l[i] <= v[j].first && v[j].first <= r[i] && dd[i] <= v[j].second && v[j].second <= u[i]){
                        sum++;
                        break;
                    }
                }
            }
            if(sum == n){
                int tmp = 0;
                for(int i=0; i<4; i++){
                    if(!(d&(1<<i))) continue;
                    printf("%d %d\n", v[i].first, v[i].second);
                    tmp = i;
                }
                for(int i=__builtin_popcount(d); i<k; i++) printf("%d %d\n", v[tmp].first, v[tmp].second);
                break;
            }
        }
    }
}

Compilation message

hamburg.cpp: In function 'int main()':
hamburg.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
hamburg.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |         scanf("%d %d %d %d", &l[i], &dd[i], &r[i], &u[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 134 ms 3448 KB Output is correct
6 Correct 158 ms 3448 KB Output is correct
7 Correct 141 ms 3576 KB Output is correct
8 Correct 139 ms 3452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 155 ms 3452 KB Output is correct
6 Correct 147 ms 3448 KB Output is correct
7 Correct 155 ms 3448 KB Output is correct
8 Correct 149 ms 3448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -