답안 #420822

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
420822 2021-06-08T14:07:19 Z Pyqe Izvanzemaljci (COI21_izvanzemaljci) C++14
5 / 100
123 ms 12780 KB
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define fr first
#define sc second

const long long ma=2e9,inf=1e18;
long long n,d;
pair<long long,long long> a[4][100069],as[4][100069];
pair<pair<long long,long long>,long long> ca[3],sq[3];

int main()
{
	long long i,j,ii,im,x,y,k,l,w,mn,mx,lh,rh,md;
	bool bad;
	
	scanf("%lld%lld",&n,&d);
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x,&y);
		a[0][i]={x,y};
	}
	for(im=0;im<4;im++)
	{
		sort(a[im]+1,a[im]+n+1);
		for(i=1;i<=n;i++)
		{
			as[im][i]={a[im][i].sc,i};
		}
		sort(as[im]+1,as[im]+n+1);
		if(im<3)
		{
			for(i=1;i<=n;i++)
			{
				x=a[im][i].fr;
				y=a[im][i].sc;
				a[im+1][i]={y,-x};
			}
		}
	}
	for(lh=1,rh=ma;lh<=rh;)
	{
		md=(lh+rh)/2;
		bad=0;
		for(im=0;im<4;im++)
		{
			if(d==1)
			{
				if(!im)
				{
					mn=inf;
					mx=-inf;
					for(i=1;i<=n;i++)
					{
						x=a[im][i].fr;
						y=a[im][i].sc;
						mn=min(mn,y);
						mx=max(mx,y);
						if(mx-mn>md||x-a[im][1].fr>md)
						{
							break;
						}
					}
					if(i>n)
					{
						bad=1;
						sq[0]={{a[im][1].fr,mn},md};
					}
				}
			}
			else if(d==2)
			{
				if(im<2)
				{
					l=0;
					for(ii=0;ii<2;ii++)
					{
						mn=inf;
						mx=-inf;
						k=l;
						for(i=l+1;i<=n;i++)
						{
							x=a[im][i].fr;
							y=a[im][i].sc;
							mn=min(mn,y);
							mx=max(mx,y);
							if(mx-mn>md||x-a[im][l+1].fr>md)
							{
								break;
							}
							if(i==n||x!=a[im][i+1].fr)
							{
								k=i;
							}
						}
						if(!ii)
						{
							ca[ii]={{a[im][k].fr-md,mn},md};
						}
						else
						{
							ca[ii]={{a[im][l+1].fr,mn},md};
						}
						l=k;
					}
					if(i>n)
					{
						bad=1;
						for(j=0;j<d;j++)
						{
							sq[j]=ca[j];
						}
					}
				}
			}
			else
			{
				if(im<2)
				{
					
				}
			}
			for(i=0;i<d;i++)
			{
				x=sq[i].fr.fr;
				y=sq[i].fr.sc;
				w=sq[i].sc;
				sq[i].fr={y,-x-w};
			}
		}
		if(bad)
		{
			rh=md-1;
		}
		else
		{
			lh=md+1;
		}
	}
	for(i=0;i<d;i++)
	{
		x=sq[i].fr.fr;
		y=sq[i].fr.sc;
		w=sq[i].sc;
		printf("%lld %lld %lld\n",x,y,w);
	}
}

Compilation message

izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  scanf("%lld%lld",&n,&d);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
izvanzemaljci.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%lld%lld",&x,&y);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 110 ms 12760 KB Output is correct
8 Correct 111 ms 12780 KB Output is correct
9 Correct 109 ms 12780 KB Output is correct
10 Correct 123 ms 12760 KB Output is correct
11 Correct 111 ms 12768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Integer -1000000000000000001 violates the range [-3*10^9, 3*10^9]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Integer 0 violates the range [1, 2*10^9]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 460 KB Integer 0 violates the range [1, 2*10^9]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 460 KB Integer 0 violates the range [1, 2*10^9]
2 Halted 0 ms 0 KB -