Submission #521480

# Submission time Handle Problem Language Result Execution time Memory
521480 2022-02-02T08:28:31 Z Kalashnikov Experiments with Gorlum (IZhO13_expgorl) C++17
100 / 100
14 ms 356 KB
#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

expgorl.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 2 ms 312 KB Output is correct
4 Correct 2 ms 308 KB Output is correct
5 Correct 2 ms 312 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 3 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 7 ms 316 KB Output is correct
10 Correct 11 ms 356 KB Output is correct
11 Correct 8 ms 332 KB Output is correct
12 Correct 11 ms 356 KB Output is correct
13 Correct 10 ms 320 KB Output is correct
14 Correct 11 ms 316 KB Output is correct
15 Correct 8 ms 336 KB Output is correct
16 Correct 11 ms 352 KB Output is correct
17 Correct 12 ms 332 KB Output is correct
18 Correct 14 ms 348 KB Output is correct
19 Correct 11 ms 352 KB Output is correct
20 Correct 12 ms 348 KB Output is correct