Submission #744035

# Submission time Handle Problem Language Result Execution time Memory
744035 2023-05-18T07:27:22 Z jamezzz Izvanzemaljci (COI21_izvanzemaljci) C++17
5 / 100
29 ms 1472 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
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

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 time Memory Grader output
1 Correct 1 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 22 ms 1420 KB Output is correct
8 Correct 22 ms 1428 KB Output is correct
9 Correct 23 ms 1424 KB Output is correct
10 Correct 24 ms 1352 KB Output is correct
11 Correct 29 ms 1472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 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 -