Submission #744239

# Submission time Handle Problem Language Result Execution time Memory
744239 2023-05-18T09:55:43 Z salmon Izvanzemaljci (COI21_izvanzemaljci) C++14
5 / 100
52 ms 2080 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());

    lmao_imagine_using_comments

    if(K == 2){
        if(N == 1){
            printf("%lld %lld %lld\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("%lld %lld %lld",v[0].first,o[0].first + (long long int )max(1,max(v[v.size()-1].first-v[0].first,o[o.size()-1].first-o[0].first)) + 1,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:43:24: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
   43 |             printf("%lld %lld %lld\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)));
      |                     ~~~^
      |                        |
      |                        long long int
      |                     %d
izvanzemaljci.cpp:43:29: warning: format '%lld' expects argument of type 'long long int', but argument 3 has type 'int' [-Wformat=]
   43 |             printf("%lld %lld %lld\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)));
      |                          ~~~^
      |                             |
      |                             long long int
      |                          %d
izvanzemaljci.cpp:43:34: warning: format '%lld' expects argument of type 'long long int', but argument 4 has type 'int' [-Wformat=]
   43 |             printf("%lld %lld %lld\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)));
      |                               ~~~^                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                  |                             |
      |                                  long long int                 int
      |                               %d
izvanzemaljci.cpp:44:24: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
   44 |             printf("%lld %lld %lld",v[0].first,o[0].first + (long long int )max(1,max(v[v.size()-1].first-v[0].first,o[o.size()-1].first-o[0].first)) + 1,1);
      |                     ~~~^
      |                        |
      |                        long long int
      |                     %d
izvanzemaljci.cpp:44:34: warning: format '%lld' expects argument of type 'long long int', but argument 4 has type 'int' [-Wformat=]
   44 |             printf("%lld %lld %lld",v[0].first,o[0].first + (long long int )max(1,max(v[v.size()-1].first-v[0].first,o[o.size()-1].first-o[0].first)) + 1,1);
      |                               ~~~^                                                                                                                        ~
      |                                  |                                                                                                                        |
      |                                  long long int                                                                                                            int
      |                               %d
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 1 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 1 ms 212 KB Output is correct
7 Correct 52 ms 2040 KB Output is correct
8 Correct 52 ms 2080 KB Output is correct
9 Correct 41 ms 2036 KB Output is correct
10 Correct 41 ms 2008 KB Output is correct
11 Correct 42 ms 1992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer 4294964065 violates the range [-3*10^9, 3*10^9]
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 -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -