답안 #1000069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000069 2024-06-16T14:52:15 Z Unforgettablepl 함박 스테이크 (JOI20_hamburg) C++17
21 / 100
3000 ms 69528 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
void strat1(int n){
    pair<int,int> curr_x = {1,1e9};
    pair<int,int> curr_y = {1,1e9};
    auto combine = [&](pair<int,int> a,pair<int,int> b){
        return make_pair(max(a.first,b.first),min(a.second,b.second));
    };
    for(int i=1;i<=n;i++){
        pair<int,int> x,y;
        cin >> x.first >> y.first >> x.second >> y.second;
        curr_x = combine(curr_x,x);
        curr_y = combine(curr_y,y);
    }
    cout << curr_x.first << ' ' << curr_y.first << '\n';
    exit(0);
}
 
bool strat2(vector<pair<pair<int,int>,pair<int,int>>> rect){
    int minR = 1e9,minU = 1e9,maxL = 1,maxD = 1;
    for(auto&[a,b]:rect){
        maxL = max(maxL,a.first);
        minR = min(minR,a.second);
        minU = min(minU,b.second);
        maxD = max(maxD,b.first);
    }
    int satisa = 0,satisb = 0;
    auto intersect = [&](pair<int,int> point,pair<pair<int,int>,pair<int,int>> rec){
        return rec.first.first <= point.first and point.first <=rec.first.second and rec.second.first <= point.second and point.second <= rec.second.second;
    };
    for(auto&i:rect){
        if(intersect({minR,minU},i) or intersect({maxL,maxD},i))satisa++;
        if(intersect({minR,maxD},i) or intersect({maxL,minU},i))satisb++;
    }
    int n = rect.size();
    if(satisa!=n and satisb!=n)return false;
    if(satisa==n)cout<<minR<<' '<<minU<<'\n'<<maxL<<' '<<maxD<<'\n';
    else cout<<minR<<' '<<maxD<<'\n'<<maxL<<' '<<minU<<'\n';
    return true;
}

bool strat3(vector<pair<pair<int,int>,pair<int,int>>> rect){
    int minR = 1e9,minU = 1e9,maxL = 1,maxD = 1;
    for(auto&[a,b]:rect){
        maxL = max(maxL,a.first);
        minR = min(minR,a.second);
        minU = min(minU,b.second);
        maxD = max(maxD,b.first);
    }
    auto intersect = [&](pair<int,int> point,pair<pair<int,int>,pair<int,int>> rec){
        return rec.first.first <= point.first and point.first <=rec.first.second and rec.second.first <= point.second and point.second <= rec.second.second;
    };
    pair<int,int> currpoint = {minR,minU};
    int iter = 0;
    t:
    vector<pair<pair<int,int>,pair<int,int>>> newrect;
    for(auto&i:rect)if(!intersect(currpoint,i))newrect.push_back(i);
    if(strat2(newrect)){
        cout << currpoint.first << ' ' << currpoint.second << '\n';
        return true;
    }
    iter++;
    if(iter==1)currpoint={minR,maxD};
    else if(iter==2)currpoint={maxL,minU};
    else if(iter==3)currpoint={maxL,maxD};
    else return false;
    goto t;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin >> n >> k;
    if(k==1)strat1(n);
    int minR = 1e9,minU = 1e9,maxL = 1,maxD = 1;
    vector<pair<pair<int,int>,pair<int,int>>> rect(n);
    vector<pair<int,int>> points;
    for(auto&[a,b]:rect){
        cin >> a.first >> b.first >> a.second >> b.second;
        maxL = max(maxL,a.first);
        minR = min(minR,a.second);
        minU = min(minU,b.second);
        maxD = max(maxD,b.first);
    }
    for(auto&[a,b]:rect){
        points.emplace_back(maxL,b.first);
        points.emplace_back(minR,b.first);
        points.emplace_back(maxL,b.second);
        points.emplace_back(minR,b.second);
        points.emplace_back(a.first,minU);
        points.emplace_back(a.first,maxD);
        points.emplace_back(a.second,minU);
        points.emplace_back(a.second,maxD);
    }
    if(k==2){
        strat2(rect);
        return 0;
    }
    if(k==3){
        strat3(rect);
        return 0;
    }
    auto intersect = [&](pair<int,int> point,pair<pair<int,int>,pair<int,int>> rec){
        return rec.first.first <= point.first and point.first <=rec.first.second and rec.second.first <= point.second and point.second <= rec.second.second;
    };
    for(auto&p:points){
        vector<pair<pair<int,int>,pair<int,int>>> newrect;
        for(auto&i:rect)if(!intersect(p,i))newrect.push_back(i);
        if(strat3(newrect)){
            cout << p.first << ' ' << p.second << '\n';
            return 0;
        }
    }
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 1 ms 984 KB Output is correct
3 Correct 1 ms 984 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 1 ms 984 KB Output is correct
3 Correct 1 ms 984 KB Output is correct
4 Correct 1 ms 848 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 984 KB Output is correct
7 Correct 1 ms 984 KB Output is correct
8 Correct 1 ms 920 KB Output is correct
9 Correct 1 ms 984 KB Output is correct
10 Correct 1 ms 984 KB Output is correct
11 Correct 1 ms 984 KB Output is correct
12 Correct 1 ms 984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 984 KB Output is correct
2 Correct 2 ms 980 KB Output is correct
3 Correct 5 ms 984 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 2 ms 1068 KB Output is correct
6 Correct 9 ms 1044 KB Output is correct
7 Correct 29 ms 1048 KB Output is correct
8 Correct 17 ms 976 KB Output is correct
9 Correct 36 ms 1060 KB Output is correct
10 Correct 12 ms 1084 KB Output is correct
11 Correct 21 ms 1052 KB Output is correct
12 Correct 6 ms 984 KB Output is correct
13 Correct 37 ms 984 KB Output is correct
14 Correct 227 ms 1068 KB Output is correct
15 Correct 49 ms 1068 KB Output is correct
16 Correct 19 ms 980 KB Output is correct
17 Correct 21 ms 1060 KB Output is correct
18 Correct 20 ms 1068 KB Output is correct
19 Correct 98 ms 1004 KB Output is correct
20 Correct 65 ms 980 KB Output is correct
21 Correct 86 ms 984 KB Output is correct
22 Correct 63 ms 1032 KB Output is correct
23 Correct 17 ms 984 KB Output is correct
24 Correct 76 ms 964 KB Output is correct
25 Correct 179 ms 984 KB Output is correct
26 Correct 19 ms 980 KB Output is correct
27 Correct 18 ms 1096 KB Output is correct
28 Correct 49 ms 1076 KB Output is correct
29 Correct 12 ms 988 KB Output is correct
30 Correct 69 ms 1016 KB Output is correct
31 Correct 148 ms 1064 KB Output is correct
32 Correct 10 ms 984 KB Output is correct
33 Correct 37 ms 1040 KB Output is correct
34 Correct 7 ms 1068 KB Output is correct
35 Correct 12 ms 984 KB Output is correct
36 Correct 27 ms 1056 KB Output is correct
37 Correct 16 ms 984 KB Output is correct
38 Correct 53 ms 984 KB Output is correct
39 Correct 32 ms 1028 KB Output is correct
40 Correct 73 ms 980 KB Output is correct
41 Correct 114 ms 980 KB Output is correct
42 Correct 49 ms 1116 KB Output is correct
43 Correct 27 ms 1052 KB Output is correct
44 Correct 26 ms 984 KB Output is correct
45 Correct 43 ms 1068 KB Output is correct
46 Correct 97 ms 1052 KB Output is correct
47 Correct 5 ms 984 KB Output is correct
48 Correct 10 ms 984 KB Output is correct
49 Correct 7 ms 1088 KB Output is correct
50 Correct 21 ms 1000 KB Output is correct
51 Correct 227 ms 1064 KB Output is correct
52 Correct 4 ms 984 KB Output is correct
53 Correct 3 ms 984 KB Output is correct
54 Correct 59 ms 1084 KB Output is correct
55 Correct 2 ms 1024 KB Output is correct
56 Correct 2 ms 1012 KB Output is correct
57 Correct 2 ms 1020 KB Output is correct
58 Correct 2 ms 984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 57 ms 4436 KB Output is correct
6 Correct 56 ms 4516 KB Output is correct
7 Correct 58 ms 4436 KB Output is correct
8 Correct 55 ms 4296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 1 ms 984 KB Output is correct
3 Correct 1 ms 984 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 72 ms 43984 KB Output is correct
6 Correct 75 ms 43932 KB Output is correct
7 Correct 73 ms 43832 KB Output is correct
8 Correct 69 ms 43908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 1 ms 984 KB Output is correct
3 Correct 1 ms 984 KB Output is correct
4 Correct 1 ms 848 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 984 KB Output is correct
7 Correct 1 ms 984 KB Output is correct
8 Correct 1 ms 920 KB Output is correct
9 Correct 1 ms 984 KB Output is correct
10 Correct 1 ms 984 KB Output is correct
11 Correct 1 ms 984 KB Output is correct
12 Correct 1 ms 984 KB Output is correct
13 Correct 78 ms 50424 KB Output is correct
14 Correct 73 ms 50840 KB Output is correct
15 Correct 73 ms 47280 KB Output is correct
16 Correct 74 ms 47736 KB Output is correct
17 Correct 76 ms 51144 KB Output is correct
18 Correct 68 ms 47036 KB Output is correct
19 Correct 72 ms 50620 KB Output is correct
20 Correct 70 ms 51388 KB Output is correct
21 Correct 84 ms 57784 KB Output is correct
22 Correct 82 ms 51180 KB Output is correct
23 Correct 75 ms 56500 KB Output is correct
24 Correct 77 ms 56504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 984 KB Output is correct
2 Correct 2 ms 980 KB Output is correct
3 Correct 5 ms 984 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 2 ms 1068 KB Output is correct
6 Correct 9 ms 1044 KB Output is correct
7 Correct 29 ms 1048 KB Output is correct
8 Correct 17 ms 976 KB Output is correct
9 Correct 36 ms 1060 KB Output is correct
10 Correct 12 ms 1084 KB Output is correct
11 Correct 21 ms 1052 KB Output is correct
12 Correct 6 ms 984 KB Output is correct
13 Correct 37 ms 984 KB Output is correct
14 Correct 227 ms 1068 KB Output is correct
15 Correct 49 ms 1068 KB Output is correct
16 Correct 19 ms 980 KB Output is correct
17 Correct 21 ms 1060 KB Output is correct
18 Correct 20 ms 1068 KB Output is correct
19 Correct 98 ms 1004 KB Output is correct
20 Correct 65 ms 980 KB Output is correct
21 Correct 86 ms 984 KB Output is correct
22 Correct 63 ms 1032 KB Output is correct
23 Correct 17 ms 984 KB Output is correct
24 Correct 76 ms 964 KB Output is correct
25 Correct 179 ms 984 KB Output is correct
26 Correct 19 ms 980 KB Output is correct
27 Correct 18 ms 1096 KB Output is correct
28 Correct 49 ms 1076 KB Output is correct
29 Correct 12 ms 988 KB Output is correct
30 Correct 69 ms 1016 KB Output is correct
31 Correct 148 ms 1064 KB Output is correct
32 Correct 10 ms 984 KB Output is correct
33 Correct 37 ms 1040 KB Output is correct
34 Correct 7 ms 1068 KB Output is correct
35 Correct 12 ms 984 KB Output is correct
36 Correct 27 ms 1056 KB Output is correct
37 Correct 16 ms 984 KB Output is correct
38 Correct 53 ms 984 KB Output is correct
39 Correct 32 ms 1028 KB Output is correct
40 Correct 73 ms 980 KB Output is correct
41 Correct 114 ms 980 KB Output is correct
42 Correct 49 ms 1116 KB Output is correct
43 Correct 27 ms 1052 KB Output is correct
44 Correct 26 ms 984 KB Output is correct
45 Correct 43 ms 1068 KB Output is correct
46 Correct 97 ms 1052 KB Output is correct
47 Correct 5 ms 984 KB Output is correct
48 Correct 10 ms 984 KB Output is correct
49 Correct 7 ms 1088 KB Output is correct
50 Correct 21 ms 1000 KB Output is correct
51 Correct 227 ms 1064 KB Output is correct
52 Correct 4 ms 984 KB Output is correct
53 Correct 3 ms 984 KB Output is correct
54 Correct 59 ms 1084 KB Output is correct
55 Correct 2 ms 1024 KB Output is correct
56 Correct 2 ms 1012 KB Output is correct
57 Correct 2 ms 1020 KB Output is correct
58 Correct 2 ms 984 KB Output is correct
59 Execution timed out 3036 ms 69528 KB Time limit exceeded
60 Halted 0 ms 0 KB -