# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
882043 | alexdd | Special graph (IZhO13_specialg) | C++17 | 0 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long double ld;
int k;
string s;
int dist(int gx, int gy, int lx, int ly)
{
return (gx-lx)*(gx-lx) + (gy-ly)*(gy-ly);
}
signed main()
{
cin>>k>>s;
k = min(k, 14LL);
int gx,gy,lx,ly;
cin>>lx>>ly>>gx>>gy;
int mnm = dist(gx,gy,lx,ly), mxm = dist(gx,gy,lx,ly);
int poz=0;
int lim = (1<<k) * (int)s.size();
for(int i=0;i<lim;i++)
{
if(s[poz]=='L')
{
gx--;
}
else if(s[poz]=='R')
{
gx++;
}
else if(s[poz]=='F')
{
gy++;
}
else if(s[poz]=='B')
{
gy--;
}
mnm = min(mnm, dist(gx,gy,lx,ly));
mxm = max(mxm, dist(gx,gy,lx,ly));
poz++;
if(poz==(int)s.size())
poz=0;
}
ld d1 = sqrt(mnm);
ld d2 = sqrt(mxm);
cout<<fixed<<setprecision(10)<<d1<<" "<<d2;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |