Submission #47596

# Submission time Handle Problem Language Result Execution time Memory
47596 2018-05-05T10:51:25 Z dqhungdl Experiments with Gorlum (IZhO13_expgorl) C++17
0 / 100
2 ms 248 KB
#include <bits/stdc++.h>
using namespace std;

long long m,n,k,s1,t1,s2,t2,vx=0,vy=0;
double minn=1e15,maxn=0;
char s[10005];

double Dist(long long u1,long long v1,long long u2,long long v2)
{
	double tmp=(u1-u2)*(u1-u2)+(v1-v2)*(v1-v2);
	return sqrt(tmp);
}

double Ternary(long long x,long long y,long long r)
{
	long long l=0;
	double rs=1e15;
	while(l<r)
	{
		long long m1=l+(r-l)/3;
		long long m2=r-(r-l)/3;
		double tmp1=Dist(x+m1*vx,y+m1*vy,s2,t2);
		double tmp2=Dist(x+m2*vx,y+m2*vy,s2,t2);
		rs=min(rs,min(tmp1,tmp2));
		if(tmp1<tmp2)
			r=m2-1;
		else
			l=m1+1;
	}
	return rs;
}

int main()
{
	ios_base::sync_with_stdio(false);
	//freopen("TEST.INP","r",stdin);
	//freopen("TEST.OUT","w",stdout);
	cin>>k>>s+1>>s1>>t1>>s2>>t2;
	n=strlen(s+1);
	for(long long i=1;i<=n;i++)
	{
		if(s[i]=='L')
			vx--;
		if(s[i]=='R')
			vx++;
		if(s[i]=='B')
			vy--;
		if(s[i]=='F')
			vy++;
	}
	minn=min(minn,Ternary(s1,t1,k));
	maxn=max(maxn,max(Dist(s1,t1,s2,t2),Dist(s1+k*vx,t1+k*vy,s2,t2)));
	for(long long i=1;i<=n;i++)
	{
		if(s[i]=='L')
			s1--;
		if(s[i]=='R')
			s1++;
		if(s[i]=='B')
			t1--;
		if(s[i]=='F')
			t1++;
		minn=min(minn,Ternary(s1,t1,k-1));
		maxn=max(maxn,max(Dist(s1,t1,s2,t2),Dist(s1+(k-1)*vx,t1+(k-1)*vy,s2,t2)));
	}
	cout<<setprecision(10)<<fixed<<minn<<' '<<maxn;
}

Compilation message

expgorl.cpp: In function 'int main()':
expgorl.cpp:38:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  cin>>k>>s+1>>s1>>t1>>s2>>t2;
          ~^~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -