Submission #47581

# Submission time Handle Problem Language Result Execution time Memory
47581 2018-05-05T06:27:26 Z dqhungdl Experiments with Gorlum (IZhO13_expgorl) C++17
0 / 100
3 ms 376 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)
{
	return sqrt((u1-u2)*(u1-u2)+(v1-v2)*(v1-v2));
}

double Ternary(long long x,long long y)
{
	long long l=0,r=k-1;
	double rs=1e15;
	while(l<=r)
	{
		long long m1=l+(r-l)/3;
		long long m2=r-(r-l)/3;
		rs=min(rs,min(Dist(x+m1*vx,y+m1*vy,s2,t2),Dist(x+m2*vx,y+m2*vy,s2,t2)));
		if(Dist(x+m1*vx,y+m1*vy,s2,t2)<Dist(x+m2*vx,y+m2*vy,s2,t2))
			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));
	maxn=max(maxn,max(Dist(s1,t1,s2,t2),Dist(s1+(k-1)*vx,t1+(k-1)*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));
		maxn=max(maxn,max(Dist(s1,t1,s2,t2),Dist(s1+(k-1)*vx,t1+(k-1)*vy,s2,t2)));
	}
	cout<<setprecision(9)<<fixed<<minn<<' '<<maxn;
}

Compilation message

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