답안 #787372

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787372 2023-07-19T06:26:01 Z 반딧불(#10031) 함박 스테이크 (JOI20_hamburg) C++17
2 / 100
240 ms 7868 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

void input();
bool check1();
bool check2();
bool check3();
bool check4();
void output();

int main(){
    input();
    if(!check1()) if(!check2()) if(!check3()) check4();
    output();
}

int n, k;
vector<int> xCoord(1), yCoord(1);
int L[200002], R[200002], D[200002], U[200002];
vector<pair<int, int> > ans;

void input(){
    scanf("%d %d", &n, &k);
    for(int i=1; i<=n; i++){
        scanf("%d %d %d %d", &L[i], &D[i], &R[i], &U[i]);
        xCoord.push_back(L[i]); xCoord.push_back(R[i]);
        yCoord.push_back(D[i]); yCoord.push_back(U[i]);
    }
    sort(xCoord.begin(), xCoord.end()); xCoord.erase(unique(xCoord.begin(), xCoord.end()), xCoord.end());
    sort(yCoord.begin(), yCoord.end()); yCoord.erase(unique(yCoord.begin(), yCoord.end()), yCoord.end());
    for(int i=1; i<=n; i++){
        L[i] = lower_bound(xCoord.begin(), xCoord.end(), L[i]) - xCoord.begin();
        R[i] = lower_bound(xCoord.begin(), xCoord.end(), R[i]) - xCoord.begin();
        D[i] = lower_bound(yCoord.begin(), yCoord.end(), D[i]) - yCoord.begin();
        U[i] = lower_bound(yCoord.begin(), yCoord.end(), U[i]) - yCoord.begin();
    }
}

bool check1(){
    int maxX = 0, maxY = 0;
    for(int i=1; i<=n; i++) maxX = max(maxX, L[i]), maxY = max(maxY, D[i]);
    for(int i=1; i<=n; i++){
        if(maxX > R[i] || maxY > U[i]) return false;
    }
    ans.push_back(make_pair(maxX, maxY));
    return true;
}

bool check2(){
    return false;
}

bool check3(){
    return false;
}

bool check4(){
    return false;
}

void output(){
    if(ans.empty()) exit(1);
    while((int)ans.size() < k) ans.push_back(ans.back());
    for(auto p: ans) printf("%d %d\n", xCoord[p.first], yCoord[p.second]);
}

Compilation message

hamburg.cpp: In function 'void input()':
hamburg.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
hamburg.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%d %d %d %d", &L[i], &D[i], &R[i], &U[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 444 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 340 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 340 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 340 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 444 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 233 ms 7792 KB Output is correct
6 Correct 234 ms 7792 KB Output is correct
7 Correct 240 ms 7740 KB Output is correct
8 Correct 233 ms 7868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 340 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 340 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 340 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -