답안 #744043

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744043 2023-05-18T07:34:02 Z jamezzz Izvanzemaljci (COI21_izvanzemaljci) C++17
5 / 100
30 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;
	for(int m=0;m<pow(k,n);++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;
				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){
			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("%d %d %d\n",ansx[i],ansy[i],ansl[i]);
	}
}

Compilation message

izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:86:8: warning: format '%d' expects argument of type 'int', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} [-Wformat=]
   86 |   pf("%d %d %d\n",ansx[i],ansy[i],ansl[i]);
      |       ~^
      |        |
      |        int
      |       %lld
izvanzemaljci.cpp:86:11: warning: format '%d' expects argument of type 'int', but argument 3 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} [-Wformat=]
   86 |   pf("%d %d %d\n",ansx[i],ansy[i],ansl[i]);
      |          ~^
      |           |
      |           int
      |          %lld
izvanzemaljci.cpp:86:14: warning: format '%d' expects argument of type 'int', but argument 4 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} [-Wformat=]
   86 |   pf("%d %d %d\n",ansx[i],ansy[i],ansl[i]);
      |             ~^
      |              |
      |              int
      |             %lld
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 1 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 22 ms 1812 KB Output is correct
8 Correct 23 ms 1876 KB Output is correct
9 Correct 30 ms 1748 KB Output is correct
10 Correct 24 ms 1756 KB Output is correct
11 Correct 22 ms 1864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 256 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 224 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 1 ms 212 KB Output is correct
2 Correct 1 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 0 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 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 18 ms 212 KB Output isn't correct
16 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 -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -