Submission #744122

#TimeUsernameProblemLanguageResultExecution timeMemory
744122jamezzzIzvanzemaljci (COI21_izvanzemaljci)C++17
5 / 100
22 ms308 KiB
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #define dbg(...) printf(__VA_ARGS__); #else #define dbg(...) #endif #define sf scanf #define pf printf #define fi first #define se second #define pb push_back #define sz(x) (int)x.size() #define all(x) x.begin(),x.end() #define INF 2023456789 typedef long long ll; typedef vector<int> vi; typedef pair<int,int> ii; #define maxn 100005 int n,k,x[maxn],y[maxn],pfxmn[maxn],pfxmx[maxn],sfxmn[maxn],sfxmx[maxn]; int main(){ sf("%d%d",&n,&k); if(k==1){ int mnx=INF,mny=INF,mxx=-INF,mxy=-INF; for(int i=0;i<n;++i){ int x,y;sf("%d%d",&x,&y); mnx=min(mnx,x); mxx=max(mxx,x); mny=min(mny,y); mxy=max(mxy,y); } pf("%d %d %d\n",mnx,mny,max(1,max(mxx-mnx,mxy-mny))); } if(k==2){ vector<ii> v; for(int i=0;i<n;++i){ sf("%d%d",&x[i],&y[i]); v.pb({x[i],y[i]}); } if(v.size()==1){ pf("%d %d 1\n%d %d 1\n",x[0],y[0],1,2e9,2e9,1); return 0; } int best=INF; vi ansx,ansy,ansl; { sort(all(v)); pfxmn[0]=pfxmx[0]=v[0].se; sfxmn[n-1]=sfxmx[n-1]=v[n-1].se; for(int i=1;i<n;++i){ pfxmn[i]=min(pfxmn[i-1],v[i].se); pfxmx[i]=max(pfxmx[i-1],v[i].se); } for(int i=n-2;i>=0;--i){ sfxmn[i]=min(sfxmn[i+1],v[i].se); sfxmx[i]=max(sfxmx[i+1],v[i].se); } for(int i=0;i<n-1;++i){ if(v[i].fi==v[i+1].fi)continue; int l1=max(1,max(v[i].fi-v[0].fi,pfxmx[i]-pfxmn[i])); int l2=max(1,max(v[n-1].fi-v[i+1].fi,sfxmx[i+1]-sfxmn[i+1])); if(max(l1,l2)<best){ best=max(l1,l2); ansx={v[i].fi-l1,v[i+1].fi}; ansy={pfxmn[i],sfxmn[i+1]}; ansl={l1,l2}; } } } { sort(all(v),[](ii &a,ii&b){return a.se<b.se;}); pfxmn[0]=pfxmx[0]=v[0].fi; sfxmn[n-1]=sfxmx[n-1]=v[n-1].fi; for(int i=1;i<n;++i){ pfxmn[i]=min(pfxmn[i-1],v[i].fi); pfxmx[i]=max(pfxmx[i-1],v[i].fi); } for(int i=n-2;i>=0;--i){ sfxmn[i]=min(sfxmn[i+1],v[i].fi); sfxmx[i]=max(sfxmx[i+1],v[i].fi); } for(int i=0;i<n-1;++i){ if(v[i].se==v[i+1].se)continue; int l1=max(1,max(v[i].se-v[0].se,pfxmx[i]-pfxmn[i])); int l2=max(1,max(v[n-1].se-v[i+1].se,sfxmx[i+1]-sfxmn[i+1])); if(max(l1,l2)<best){ best=max(l1,l2); ansx={pfxmn[i],sfxmn[i+1]}; ansy={v[i].se-l1,v[i+1].se}; ansl={l1,l2}; } } } for(int i=0;i<2;++i){ pf("%d %d %d\n",ansx[i],ansy[i],ansl[i]); } } }

Compilation message (stderr)

izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:45:21: warning: format '%d' expects argument of type 'int', but argument 5 has type 'double' [-Wformat=]
   45 |    pf("%d %d 1\n%d %d 1\n",x[0],y[0],1,2e9,2e9,1);
      |                    ~^                  ~~~
      |                     |                  |
      |                     int                double
      |                    %f
izvanzemaljci.cpp:45:7: warning: too many arguments for format [-Wformat-extra-args]
   45 |    pf("%d %d 1\n%d %d 1\n",x[0],y[0],1,2e9,2e9,1);
      |       ^~~~~~~~~~~~~~~~~~~~
izvanzemaljci.cpp:26:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  sf("%d%d",&n,&k);
      |    ^
izvanzemaljci.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |    int x,y;sf("%d%d",&x,&y);
      |              ^
izvanzemaljci.cpp:41:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |    sf("%d%d",&x[i],&y[i]);
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...