Submission #744069

# Submission time Handle Problem Language Result Execution time Memory
744069 2023-05-18T07:50:54 Z jamezzz Izvanzemaljci (COI21_izvanzemaljci) C++17
5 / 100
33 ms 3728 KB
#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
#define LINF 1023456789123456789
typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> ii;

#define maxn 300005

int n,k;
ll x[maxn],y[maxn];

inline int in(ll a,ll b,ll x,ll y,ll x2,ll 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("%lld%lld",&x[i],&y[i]);
	}
	ll best=LINF;
	vi ansx,ansy,ansl;
	int msk=1;
	for(int i=0;i<n;++i)msk*=k;
	for(int m=0;m<msk;++m){
		int tm=m;
		
		vi mnx(k,LINF),mxx(k,-LINF),mny(k,LINF),mxy(k,-LINF);
		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;
		int cnt=0;
		for(int i=0;i<k;++i){
			if(mnx[i]==LINF){
				if(cnt==0)mnx[i]=mxx[i]=mny[i]=mxy[i]=-(ll)3*1e9;
				else mnx[i]=mxx[i]=mny[i]=mxy[i]=(ll)3*1e9;
				++cnt;
			}
		}
		for(int i=0;i<k;++i){
			for(int j=0;j<k;++j){
				if(i==j)continue;
				ll l=max(1ll,max(mxx[j]-mnx[j],mxy[j]-mny[j]));
				if(in(mnx[i],mny[i],mnx[j],mny[j],mnx[j]+l,mny[j]+l))good=false;
				if(in(mnx[i],mxy[i],mnx[j],mny[j],mnx[j]+l,mny[j]+l))good=false;
				if(in(mxx[i],mny[i],mnx[j],mny[j],mnx[j]+l,mny[j]+l))good=false;
				if(in(mxx[i],mxy[i],mnx[j],mny[j],mnx[j]+l,mny[j]+l))good=false;
			}
		}
		if(good){
			ll mx=0;
			vi cx,cy,cl;
			for(int i=0;i<k;++i){
				cx.pb(mnx[i]);
				cy.pb(mny[i]);
				cl.pb(max(1ll,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("%lld %lld %lld\n",ansx[i],ansy[i],ansl[i]);
	}
}

Compilation message

izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:32:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  sf("%d%d",&n,&k);
      |    ^
izvanzemaljci.cpp:35:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   sf("%lld%lld",&x[i],&y[i]);
      |     ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 27 ms 3712 KB Output is correct
8 Correct 28 ms 3688 KB Output is correct
9 Correct 27 ms 3728 KB Output is correct
10 Correct 27 ms 3684 KB Output is correct
11 Correct 33 ms 3660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Runtime error 1 ms 452 KB Execution killed with signal 6
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 17 ms 304 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -