답안 #744072

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744072 2023-05-18T07:51:52 Z jamezzz Izvanzemaljci (COI21_izvanzemaljci) C++17
5 / 100
27 ms 1876 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){
			ll l2=max(1ll,max(mxx[i]-mnx[i],mxy[i]-mny[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],mny[i]+l2,mnx[j],mny[j],mnx[j]+l,mny[j]+l))good=false;
				if(in(mnx[i]+l2,mny[i],mnx[j],mny[j],mnx[j]+l,mny[j]+l))good=false;
				if(in(mnx[i]+l2,mny[i]+l2,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]);
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
7 Correct 25 ms 1844 KB Output is correct
8 Correct 27 ms 1740 KB Output is correct
9 Correct 27 ms 1836 KB Output is correct
10 Correct 25 ms 1876 KB Output is correct
11 Correct 24 ms 1740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Runtime error 1 ms 468 KB Execution killed with signal 6
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 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 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 16 ms 308 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 400 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -