Submission #744150

#TimeUsernameProblemLanguageResultExecution timeMemory
744150jamezzzIzvanzemaljci (COI21_izvanzemaljci)C++17
26 / 100
56 ms8760 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #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]; main(){ sf("%lld%lld",&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("%lld%lld",&x,&y); mnx=min(mnx,x); mxx=max(mxx,x); mny=min(mny,y); mxy=max(mxy,y); } pf("%lld %lld %lld\n",mnx,mny,max(1ll,max(mxx-mnx,mxy-mny))); } if(k==2){ vector<ii> v; for(int i=0;i<n;++i){ sf("%lld%lld",&x[i],&y[i]); v.pb({x[i],y[i]}); } if(v.size()==1){ pf("%lld %lld 1\n2000000000 2000000000 1\n",x[0],y[0]); 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(1ll,max(v[i].fi-v[0].fi,pfxmx[i]-pfxmn[i])); int l2=max(1ll,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(1ll,max(v[i].se-v[0].se,pfxmx[i]-pfxmn[i])); int l2=max(1ll,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("%lld %lld %lld\n",ansx[i],ansy[i],ansl[i]); } } } /* 4 2 1000000000 1000000000 -1000000000 -1000000000 1000000000 -1000000000 -1000000000 1000000000 */

Compilation message (stderr)

izvanzemaljci.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   27 | main(){
      | ^~~~
izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:28:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  sf("%lld%lld",&n,&k);
      |    ^
izvanzemaljci.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |    int x,y;sf("%lld%lld",&x,&y);
      |              ^
izvanzemaljci.cpp:43:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |    sf("%lld%lld",&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...