Submission #744041

# Submission time Handle Problem Language Result Execution time Memory
744041 2023-05-18T07:32:57 Z jamezzz Izvanzemaljci (COI21_izvanzemaljci) C++17
5 / 100
36 ms 1844 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

ll 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("%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:31:7: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll*' {aka 'long long int*'} [-Wformat=]
   31 |  sf("%d%d",&n,&k);
      |      ~^    ~~
      |       |    |
      |       int* ll* {aka long long int*}
      |      %lld
izvanzemaljci.cpp:31:9: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'll*' {aka 'long long int*'} [-Wformat=]
   31 |  sf("%d%d",&n,&k);
      |        ~^     ~~
      |         |     |
      |         int*  ll* {aka long long int*}
      |        %lld
izvanzemaljci.cpp:85: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=]
   85 |   pf("%d %d %d\n",ansx[i],ansy[i],ansl[i]);
      |       ~^
      |        |
      |        int
      |       %lld
izvanzemaljci.cpp:85: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=]
   85 |   pf("%d %d %d\n",ansx[i],ansy[i],ansl[i]);
      |          ~^
      |           |
      |           int
      |          %lld
izvanzemaljci.cpp:85: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=]
   85 |   pf("%d %d %d\n",ansx[i],ansy[i],ansl[i]);
      |             ~^
      |              |
      |              int
      |             %lld
izvanzemaljci.cpp:31:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  sf("%d%d",&n,&k);
      |    ^
izvanzemaljci.cpp:34:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |   sf("%lld%lld",&x[i],&y[i]);
      |     ^
# Verdict Execution time Memory 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 24 ms 1844 KB Output is correct
8 Correct 25 ms 1840 KB Output is correct
9 Correct 24 ms 1776 KB Output is correct
10 Correct 36 ms 1796 KB Output is correct
11 Correct 34 ms 1804 KB Output is correct
# 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 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 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 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 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 300 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 308 KB Output is correct
15 Incorrect 19 ms 308 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 -