답안 #4770

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
4770 2014-01-01T09:50:29 Z gs13068 생물 실험 (IZhO13_expgorl) C++
75 / 100
12 ms 1188 KB
#include<cstdio>
#include<cmath>
#include<cstring>

char str[10002];
int x[10000];
int y[10000];

inline long double dist(int x,int y)
{
	return sqrtl(1LL*x*x+1LL*y*y);
}

int main()
{
	int a,b,c,d;
	int i,j,n,k;
	int l,r,t1,t2;
	long double min=1.0E6,max=0.0,temp;
	scanf("%d%s%d%d%d%d",&k,str+1,&a,&b,&c,&d);
	n=strlen(str+1);
	x[0]=c-a;
	y[0]=d-b;
	for(i=1;i<=n;i++)
	{
		x[i]=x[i-1];
		y[i]=y[i-1];
		switch(str[i])
		{
		case 'L':
			x[i]--;
			break;
		case 'R':
			x[i]++;
			break;
		case 'F':
			y[i]++;
			break;
		case 'B':
			y[i]--;
			break;
		}
	}
	for(i=0;i<=n;i++)
	{
		l=0;
		r=k-1;
		while(r-l>10)
		{
			t1=(2*l+r)/3;
			t2=(l+2*r)/3;
			if(dist(x[i]+(x[n]-x[0])*t1,y[i]+(y[n]-y[0])*t1)>dist(x[i]+(x[n]-x[0])*t2,y[i]+(y[n]-y[0])*t2))
				l=t1;
			else
				r=t2;
		}
		for(j=(l-10>0?l-10:0);j<(r+10<k?r+10:k);j++)
		{
			temp=dist(x[i]+(x[n]-x[0])*j,y[i]+(y[n]-y[0])*j);
			if(temp<min)min=temp;
		}
		temp=dist(x[i],y[i]);
		if(temp>max)max=temp;
		temp=dist(x[i]+(x[n]-x[0])*(k-1),y[i]+(y[n]-y[0])*(k-1));
		if(temp>max)max=temp;
	}
	printf("%.20Lf %.20Lf",min,max);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1188 KB Output is correct
2 Correct 0 ms 1188 KB Output is correct
3 Correct 0 ms 1188 KB Output is correct
4 Correct 0 ms 1188 KB Output is correct
5 Correct 0 ms 1188 KB Output is correct
6 Correct 0 ms 1188 KB Output is correct
7 Correct 0 ms 1188 KB Output is correct
8 Correct 0 ms 1188 KB Output is correct
9 Correct 8 ms 1188 KB Output is correct
10 Correct 12 ms 1188 KB Output is correct
11 Correct 4 ms 1188 KB Output is correct
12 Correct 12 ms 1188 KB Output is correct
13 Correct 12 ms 1188 KB Output is correct
14 Correct 8 ms 1188 KB Output is correct
15 Correct 8 ms 1188 KB Output is correct
16 Incorrect 8 ms 1188 KB Output isn't correct
17 Incorrect 12 ms 1188 KB Output isn't correct
18 Incorrect 12 ms 1188 KB Output isn't correct
19 Incorrect 12 ms 1188 KB Output isn't correct
20 Incorrect 12 ms 1188 KB Output isn't correct