Submission #502099

#TimeUsernameProblemLanguageResultExecution timeMemory
502099khangalExperiments with Gorlum (IZhO13_expgorl)C++14
100 / 100
18 ms29344 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef double db; typedef vector<long long> vl; typedef pair<long long, long long > pl; const int N = 1e6 + 1; #define po pop_back #define pb push_back #define mk make_pair #define lw lower_bound #define up upper_bound #define ff first #define ss second #define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0); #define MOD 1000000007 #define MAX 1e18 #define MIN -1e18 #define per(i,a,b) for(ll i=b;i>=a;i--) #define con continue #define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); #define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628 //typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; template< typename T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; ll n, m, ans, mid, mn, mx, cnt, sum, h1, h2, arr[3234567],arr1[1234567], sz, k, i, j, h, a, w, x, y, z,par[1234567]; bool used[1234567]; ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},c1[123][123]; vector<ll> edge[1234567]; ll jump[22][223456]; ll lvl[1234567]; //ll bit[1234567]; //ll timer; //ll st[1234567],endd[1234567]; //ll dp[5005][5005]; ll power(ll base, ll val, ll mod) { ll res = 1; while (val) { if (val % 2 == 1) { res = res * base; } base = base * base; base %= mod; res %= mod; val /= 2; } return res; } bool comp(pl x,pl y){ if(x.ff>y.ff)return true; return false; } ll find(ll x){ if(x==par[x])return x; else return par[x]=find(par[x]); } ll f(ll n,ll k){ if(n==1)return 1; if(k<=(n+1)/2){ if(2*k>n) return (2*k)%n; return (2*k); } ll res= f(n/2 , k-(n+1)/2); if(n%2 == 1)return res*2+1; else return res*2-1; } ll fac[1234567]; void init(){ fac[0]=1; for(int i=1;i<=1000000;i++)fac[i]=fac[i-1]*i%MOD; } void dfs(ll node,ll par,ll level){ lvl[node]=level; jump[0][node] = par; for(auto u:edge[node]){ if(u!=par){ dfs(u,node,level+1); } } } void process_LCA(){ for(int i=1;(1<<i)<=n;i++){ for(int j=1;j<=n;j++){ jump[i][j] = jump[i-1][jump[i-1][j]]; } } } ll LCA(ll x,ll y){ if(lvl[x] < lvl[y])swap(x,y); ll diss = lvl[x] - lvl[y]; for(int i=21;i>=0;i--){ if((1<<i)&diss){ x = jump[i][x]; } } if(x==y)return x; for(int i=21;i>=0;i--){ if(jump[i][x] != jump[i][y]){ x = jump[i][x]; y = jump[i][y]; } } return jump[0][x]; } double dis(double x,double y){ return sqrt(x*x + y*y); } class A { public: static void funcA() { cin>>k; string s; cin>>s; cin>>x>>y; ll xx,yy; cin>>xx>>yy; xx-=x; yy-=y; ll x1=0,y1=0; for(auto u:s){ if(u=='L')x1+=dx[0],y1+=dy[0]; if(u=='R')x1+=dx[1],y1+=dy[1]; if(u=='B')x1+=dx[2],y1+=dy[2]; if(u=='F')x1+=dx[3],y1+=dy[3]; } double ans1=MAX,ans2=0; for(auto u:s){ ll l=0,r=k-1; while(l<r){ ll mid=(l+r)/2; double a = dis(mid * x1 + xx , mid*y1 + yy); double b = dis((mid+1) * x1 + xx , (mid+1)*y1 + yy); if(a<b) r=mid; else l=mid+1; ans1=min(ans1 , a); ans1=min(ans1 , b); } ans2=max(ans2 , dis(xx , yy)); ans2=max(ans2 , dis(xx +(k-1)*x1 , yy + (k-1)*y1)); if(u=='L')xx+=dx[0],yy+=dy[0]; if(u=='R')xx+=dx[1],yy+=dy[1]; if(u=='B')xx+=dx[2],yy+=dy[2]; if(u=='F')xx+=dx[3],yy+=dy[3]; } printf("%.10f %.10f",ans1,ans2); } }lol; void solve() { A::funcA(); } int main() { ll T = 1; //cin>>T; boost; while (T--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...