답안 #744124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744124 2023-05-18T08:24:26 Z jamezzz Izvanzemaljci (COI21_izvanzemaljci) C++17
5 / 100
24 ms 300 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 100005
 
int n,k,x[maxn],y[maxn],pfxmn[maxn],pfxmx[maxn],sfxmn[maxn],sfxmx[maxn];
 
int main(){
	sf("%d%d",&n,&k);
	if(k==1){
		int mnx=INF,mny=INF,mxx=-INF,mxy=-INF;
		for(int i=0;i<n;++i){
			int x,y;sf("%d%d",&x,&y);
			mnx=min(mnx,x);
			mxx=max(mxx,x);
			mny=min(mny,y);
			mxy=max(mxy,y);
		}
		pf("%d %d %d\n",mnx,mny,max(1,max(mxx-mnx,mxy-mny)));
	}
	if(k==2){
		vector<ii> v;
		for(int i=0;i<n;++i){
			sf("%d%d",&x[i],&y[i]);
			v.pb({x[i],y[i]});
		}
		if(v.size()==1){
			pf("%d %d 1\n2000000000 2000000000 1\n",x[0],y[0]);
			return 0;
		}
		
		int best=INF;
		vi ansx,ansy,ansl;
		
		{
			sort(all(v));
			pfxmn[0]=pfxmx[0]=v[0].se;
			sfxmn[n-1]=sfxmx[n-1]=v[n-1].se;
			for(int i=1;i<n;++i){
				pfxmn[i]=min(pfxmn[i-1],v[i].se);
				pfxmx[i]=max(pfxmx[i-1],v[i].se);
			}
			for(int i=n-2;i>=0;--i){
				sfxmn[i]=min(sfxmn[i+1],v[i].se);
				sfxmx[i]=max(sfxmx[i+1],v[i].se);
			}
			for(int i=0;i<n-1;++i){
				if(v[i].fi==v[i+1].fi)continue;
				int l1=max(1,max(v[i].fi-v[0].fi,pfxmx[i]-pfxmn[i]));
				int l2=max(1,max(v[n-1].fi-v[i+1].fi,sfxmx[i+1]-sfxmn[i+1]));
				if(max(l1,l2)<best){
					best=max(l1,l2);
					ansx={v[i].fi-l1,v[i+1].fi};
					ansy={pfxmn[i],sfxmn[i+1]};
					ansl={l1,l2};
				}
			}
		}
		{
			sort(all(v),[](ii &a,ii&b){return a.se<b.se;});
			pfxmn[0]=pfxmx[0]=v[0].fi;
			sfxmn[n-1]=sfxmx[n-1]=v[n-1].fi;
			for(int i=1;i<n;++i){
				pfxmn[i]=min(pfxmn[i-1],v[i].fi);
				pfxmx[i]=max(pfxmx[i-1],v[i].fi);
			}
			for(int i=n-2;i>=0;--i){
				sfxmn[i]=min(sfxmn[i+1],v[i].fi);
				sfxmx[i]=max(sfxmx[i+1],v[i].fi);
			}
			for(int i=0;i<n-1;++i){
				if(v[i].se==v[i+1].se)continue;
				int l1=max(1,max(v[i].se-v[0].se,pfxmx[i]-pfxmn[i]));
				int l2=max(1,max(v[n-1].se-v[i+1].se,sfxmx[i+1]-sfxmn[i+1]));
				if(max(l1,l2)<best){
					best=max(l1,l2);
					ansx={pfxmn[i],sfxmn[i+1]};
					ansy={v[i].se-l1,v[i+1].se};
					ansl={l1,l2};
				}
			}
		}
		for(int i=0;i<2;++i){
			pf("%d %d %d\n",ansx[i],ansy[i],ansl[i]);
		}
	}
}

Compilation message

izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:26:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  sf("%d%d",&n,&k);
      |    ^
izvanzemaljci.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |    int x,y;sf("%d%d",&x,&y);
      |              ^
izvanzemaljci.cpp:41:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |    sf("%d%d",&x[i],&y[i]);
      |      ^
# 결과 실행 시간 메모리 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 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 212 KB Output is correct
8 Correct 22 ms 296 KB Output is correct
9 Correct 21 ms 212 KB Output is correct
10 Correct 22 ms 300 KB Output is correct
11 Correct 24 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 0 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 0 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -