Submission #521480

#TimeUsernameProblemLanguageResultExecution timeMemory
521480KalashnikovExperiments with Gorlum (IZhO13_expgorl)C++17
100 / 100
14 ms356 KiB
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
 
using namespace std;
using ll = long long;
 
const int N = 2e5+5 , inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7 , P = 6547;

long double mn = INF , mx = -INF;
long double lx , ly;
long double gx , gy;
long double cx , cy;

long double calc(long double gx , long double gy) {
	long double A = lx-gx;
	long double B = ly-gy;
	long double res = sqrt(A*A + B*B);
	return res;
}

void solve(int tc) {
	int k;
	string s;
	cin >> k;
	cin >> s;
	cin >> lx >> ly >> gx >> gy;
	for(auto to: s) {
		if(to == 'L') cx --;
		if(to == 'R') cx ++;
		if(to == 'F') cy ++;
		if(to == 'B') cy --;
	}
	long double curx = 0, cury = 0;
	for(auto to: s) {
		if(to == 'L') curx --;
		if(to == 'R') curx ++;
		if(to == 'F') cury ++;
		if(to == 'B') cury --;
		int l = 0 , r = k-1;
		while(l <= r) {
			int m1 = l + (r-l)/3;
			int m2 = r - (r-l)/3;
			long double g1x = gx + cx*m1 + curx , g1y = gy + cy*m1 + cury;
			long double g2x = gx + cx*m2 + curx , g2y = gy + cy*m2 + cury;
			mn = min(mn , calc(g1x,  g1y));
			mn = min(mn , calc(g2x,  g2y));
			if(calc(g1x,  g1y) < calc(g2x , g2y)) {
				r = m2-1;
			}
			else {
				l = m1+1;
			}
		}
		mx = max(mx , calc(gx + curx , gy + cury));
		mx = max(mx , calc(gx + curx + (k-1)*cx, gy + cury + (k-1)*cy));
	}
	cout << fixed << setprecision(17) << mn << ' ' << mx;
}
/*
*/
main() {
    ios;
    int tt = 1 , tc = 0;
    // cin >> tt;
    while(tt --) {
        solve(++tc);
    }
    return 0;
}

Compilation message (stderr)

expgorl.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...