Submission #744035

#TimeUsernameProblemLanguageResultExecution timeMemory
744035jamezzzIzvanzemaljci (COI21_izvanzemaljci)C++17
5 / 100
29 ms1472 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 300005 int n,k,x[maxn],y[maxn]; inline int in(int a,int b,int x,int y,int x2,int y2){ return x<=a&&a<=x2&&y<=b&&b<=y2; } int main(){ sf("%d%d",&n,&k); assert(k==1||n<=12); for(int i=0;i<n;++i){ sf("%d%d",&x[i],&y[i]); } int best=INF; vi ansx,ansy,ansl; vector<int> num(n); for(int m=0;m<pow(k,n);++m){ int tm=m; vi mnx(k,INF),mxx(k,-INF),mny(k,INF),mxy(k,-INF); for(int i=0;i<n;++i){ int c=tm%k; tm/=k; mnx[c]=min(mnx[c],x[i]); mxx[c]=max(mxx[c],x[i]); mny[c]=min(mny[c],y[i]); mxy[c]=max(mxy[c],y[i]); } bool good=true; for(int i=0;i<k;++i){ if(mnx[i]==INF)good=false; for(int j=0;j<k;++j){ if(i==j)continue; if(in(mnx[i],mny[i],mnx[j],mny[j],mxx[j],mxy[j]))good=false; if(in(mnx[i],mxy[i],mnx[j],mny[j],mxx[j],mxy[j]))good=false; if(in(mxx[i],mny[i],mnx[j],mny[j],mxx[j],mxy[j]))good=false; if(in(mxx[i],mxy[i],mnx[j],mny[j],mxx[j],mxy[j]))good=false; } } if(good){ int mx=0; vector<int> cx,cy,cl; for(int i=0;i<k;++i){ cx.pb(mnx[i]); cy.pb(mny[i]); cl.pb(max(1,max(mxx[i]-mnx[i],mxy[i]-mny[i]))); mx=max(mx,cl.back()); } if(mx<best){ best=mx; swap(cx,ansx); swap(cy,ansy); swap(cl,ansl); } } } for(int i=0;i<k;++i){ pf("%d %d %d\n",ansx[i],ansy[i],ansl[i]); } }

Compilation message (stderr)

izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:30:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  sf("%d%d",&n,&k);
      |    ^
izvanzemaljci.cpp:33:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   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...