Submission #744250

# Submission time Handle Problem Language Result Execution time Memory
744250 2023-05-18T09:59:00 Z salmon Izvanzemaljci (COI21_izvanzemaljci) C++17
26 / 100
57 ms 5780 KB
#define verytrivial else if(K == 1) printf("%d %d %d",v[0].first,o[0].first,max(1,max(v[v.size()-1].first-v[0].first,o[o.size()-1].first-o[0].first)));
#define lmao_imagine_using_comments for(int i = 0; i > 0; i++) printf(" sdakjol");

#include <bits/stdc++.h>
using namespace std;

vector<pair<int,int>> v;
vector<pair<int,int>> o;
int N,K;
int a,b;
int smolxleft[100100];
int smolxright[100100];
int bigxleft[100100];
int bigxright[100100];
int smolyleft[100100];
int smolyright[100100];
int bigyleft[100100];
int bigyright[100100];


int main(){
    scanf(" %d",&N);
    scanf(" %d",&K);

    int smalla,smallb;
    int biga,bigb;

    for(int i = 0; i < N; i++){
        scanf(" %d",&a);
        scanf(" %d",&b);

        v.push_back(make_pair(a,b));
        o.push_back(make_pair(b,a));
    }

    sort(v.begin(),v.end());
    sort(o.begin(),o.end());

    if(K == 2){
        if(N == 1){
            printf("%d %d %d\n",v[0].first,o[0].first,max(1,max(v[v.size()-1].first-v[0].first,o[o.size()-1].first-o[0].first)));
            printf("%d %d %d",v[0].first,o[0].first - 2,1);
            return 0;
        }

        smolxleft[0] = v[0].second;
        bigxleft[0] = v[0].second;

        for(int i = 1; i < N; i++){
            smolxleft[i] = min(smolxleft[i - 1],v[i].second);
            bigxleft[i] = max(bigxleft[i - 1],v[i].second);
        }

        smolxright[N - 1] = v[N - 1].second;
        bigxright[N - 1] = v[N - 1].second;

        for(int i = N - 2; i >= 0; i--){
            smolxright[i] = min(smolxright[i + 1],v[i].second);
            bigxright[i] = max(bigxright[i + 1],v[i].second);
        }

        //dane

        smolyleft[0] = o[0].second;
        bigyleft[0] = o[0].second;

        for(int i = 1; i < N; i++){
            smolyleft[i] = min(smolyleft[i - 1],o[i].second);
            bigyleft[i] = max(bigyleft[i - 1],o[i].second);
        }

        smolyright[N - 1] = o[N - 1].second;
        bigyright[N - 1] = o[N - 1].second;

        for(int i = N - 2; i >= 0; i--){
            smolyright[i] = min(smolyright[i + 1],o[i].second);
            bigyright[i] = max(bigyright[i + 1],o[i].second);
        }

        pair<long long int,pair<pair<long long int,pair<long long int,long long int>>,pair<long long int,pair<long long int,long long int>>>> ans = make_pair(((long long int)2000100100) * 500,make_pair(make_pair(-1,make_pair(0,0)),make_pair(-1,make_pair(0,0))));

        for(int i = 0; i < N - 1; i++){
            if(v[i].first == v[i + 1].first){
                continue;
            }

            long long int t1 = bigxleft[i];
            long long int b1 = smolxleft[i];
            long long int t2 = bigxright[i + 1];
            long long int b2 = smolxright[i + 1];

            long long int l1 = max((long long int)1,max(t1 - b1, (long long int)v[i].first - v[0].first));
            long long int l2 = max((long long int)1,max(t2 - b2, (long long int)v[N - 1].first - v[i + 1].first));

            pair<long long int,pair<long long int,long long int>> sq1 = make_pair(l1,make_pair(v[i].first - l1,b1));
            pair<long long int,pair<long long int,long long int>> sq2 = make_pair(l2,make_pair(((long long int)v[i + 1].first),b2));

            ans = min(ans,make_pair(max(sq1.first,sq2.first),make_pair(sq1,sq2)));
        }

        for(int i = 0; i < N - 1; i++){
            if(o[i].first == o[i + 1].first){
                continue;
            }

            long long int t1 = bigyleft[i];
            long long int b1 = smolyleft[i];
            long long int t2 = bigyright[i + 1];
            long long int b2 = smolyright[i + 1];

            long long int l1 = max((long long int)1,max(t1 - b1, (long long int)o[i].first - o[0].first));
            long long int l2 = max((long long int)1,max(t2 - b2, (long long int)o[N - 1].first - o[i + 1].first));

            pair<long long int,pair<long long int,long long int>> sq1 = make_pair(l1,make_pair(b1,o[i].first - l1));
            pair<long long int,pair<long long int,long long int>> sq2 = make_pair(l2,make_pair(b2,((long long int)o[i + 1].first)));

            ans = min(ans,make_pair(max(sq1.first,sq2.first),make_pair(sq1,sq2)));
        }


        pair<long long int,pair<long long int,long long int>> sq1 = ans.second.first;
        pair<long long int,pair<long long int,long long int>> sq2 = ans.second.second;


        printf("%lld %lld %lld\n",sq1.second.first,sq1.second.second,sq1.first);
        printf("%lld %lld %lld\n",sq2.second.first,sq2.second.second,sq2.first);

    }
    verytrivial

}
/*
1 2
3 1


*/

Compilation message

izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:25:9: warning: unused variable 'smalla' [-Wunused-variable]
   25 |     int smalla,smallb;
      |         ^~~~~~
izvanzemaljci.cpp:25:16: warning: unused variable 'smallb' [-Wunused-variable]
   25 |     int smalla,smallb;
      |                ^~~~~~
izvanzemaljci.cpp:26:9: warning: unused variable 'biga' [-Wunused-variable]
   26 |     int biga,bigb;
      |         ^~~~
izvanzemaljci.cpp:26:14: warning: unused variable 'bigb' [-Wunused-variable]
   26 |     int biga,bigb;
      |              ^~~~
izvanzemaljci.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf(" %d",&N);
      |     ~~~~~^~~~~~~~~~
izvanzemaljci.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf(" %d",&K);
      |     ~~~~~^~~~~~~~~~
izvanzemaljci.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf(" %d",&a);
      |         ~~~~~^~~~~~~~~~
izvanzemaljci.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         scanf(" %d",&b);
      |         ~~~~~^~~~~~~~~~
# 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 43 ms 2100 KB Output is correct
8 Correct 45 ms 1992 KB Output is correct
9 Correct 40 ms 2052 KB Output is correct
10 Correct 39 ms 1992 KB Output is correct
11 Correct 54 ms 2032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 55 ms 5780 KB Output is correct
11 Correct 52 ms 5668 KB Output is correct
12 Correct 57 ms 5696 KB Output is correct
13 Correct 56 ms 5704 KB Output is correct
14 Correct 51 ms 5732 KB Output is correct
15 Correct 55 ms 5684 KB Output is correct
16 Correct 52 ms 5624 KB Output is correct
17 Correct 49 ms 5344 KB Output is correct
18 Correct 44 ms 5088 KB Output is correct
19 Correct 40 ms 4772 KB Output is correct
20 Correct 41 ms 5064 KB Output is correct
21 Correct 47 ms 5716 KB Output is correct
22 Correct 45 ms 5668 KB Output is correct
23 Correct 46 ms 5628 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 1 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 -