Submission #681694

# Submission time Handle Problem Language Result Execution time Memory
681694 2023-01-13T17:51:01 Z qwerasdfzxcl Izvanzemaljci (COI21_izvanzemaljci) C++17
26 / 100
42 ms 3916 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
struct Square{
    ll l, x, y;
    Square(){}
    Square(ll _l, ll _x, ll _y): l(_l), x(_x), y(_y) {}

    void print(){printf("%lld %lld %lld\n", x, y, l);}
};
pair<int, int> a[100100];
int mn[100100], mx[100100];

void solve1(int n){
    sort(a+1, a+n+1);
    int y1 = a[1].second, y2 = a[1].second;
    for (int i=1;i<=n;i++){
        y1 = min(y1, a[i].second);
        y2 = max(y2, a[i].second);
    }

    Square ans(max(max(a[n].first-a[1].first, y2-y1), 1), a[1].first, y1);
    ans.print();
}

pair<int, pair<Square, Square>> solve2x(int n){
    sort(a+1, a+n+1);
    a[n+1].first = 1e9+100;
    mn[n] = a[n].second;
    mx[n] = a[n].second;
    for (int i=n-1;i>0;i--){
        mn[i] = min(mn[i+1], a[i].second);
        mx[i] = max(mx[i+1], a[i].second);
    }

    int y1 = 1e9, y2 = -1e9, ans = 2e9 + 100;
    pair<Square, Square> ret;
    for (int i=1;i<=n;i++){
        y1 = min(y1, a[i].second);
        y2 = max(y2, a[i].second);

        int L1 = max(y2-y1, a[i].first-a[1].first);
        int L2 = max(mx[i+1]-mn[i+1], a[n].first-a[i+1].first);
        L1 = max(L1, 1);
        L2 = max(L2, 1);

        if (ans > max(L1, L2) && a[i].first < a[i+1].first){
            ans = max(L1, L2);
            ret = make_pair(Square(L1, (ll)a[i].first-L1, (ll)y1), Square(L2, (ll)a[i+1].first, (ll)mn[i+1]));
        }
    }

    return {ans, ret};
}

void solve2(int n){
    auto [ans1, p1] = solve2x(n);
    for (int i=1;i<=n;i++) swap(a[i].first, a[i].second);
    auto [ans2, p2] = solve2x(n);

    auto p = p1;
    if (ans2 < ans1){
        p = p2;
        swap(p.first.x, p.first.y);
        swap(p.second.x, p.second.y);
    }

    p.first.print();
    p.second.print();
}

void solve3(int n){

}

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i=1;i<=n;i++) scanf("%d %d", &a[i].first, &a[i].second);
    if (k==1) solve1(n);
    if (k==2) solve2(n);
    if (k==3) solve3(n);
    return 0;
}

Compilation message

izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:79:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
izvanzemaljci.cpp:80:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |     for (int i=1;i<=n;i++) scanf("%d %d", &a[i].first, &a[i].second);
      |                            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 30 ms 1100 KB Output is correct
8 Correct 29 ms 1072 KB Output is correct
9 Correct 29 ms 980 KB Output is correct
10 Correct 32 ms 972 KB Output is correct
11 Correct 38 ms 984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 40 ms 3876 KB Output is correct
11 Correct 39 ms 3916 KB Output is correct
12 Correct 39 ms 3784 KB Output is correct
13 Correct 40 ms 3784 KB Output is correct
14 Correct 39 ms 3788 KB Output is correct
15 Correct 42 ms 3884 KB Output is correct
16 Correct 39 ms 3788 KB Output is correct
17 Correct 35 ms 3532 KB Output is correct
18 Correct 41 ms 3388 KB Output is correct
19 Correct 32 ms 3036 KB Output is correct
20 Correct 32 ms 3276 KB Output is correct
21 Correct 40 ms 3856 KB Output is correct
22 Correct 39 ms 3748 KB Output is correct
23 Correct 39 ms 3812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -