Submission #894647

#TimeUsernameProblemLanguageResultExecution timeMemory
894647heeheeheehaawExperiments with Gorlum (IZhO13_expgorl)C++17
100 / 100
2 ms1012 KiB
#include <bits/stdc++.h> #define int long long using namespace std; typedef long double ld; struct point { int x, y; }; int dist(int x1, int y1, int x2, int y2) { return ((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)); } signed main() { int k; cin>>k; string s; cin>>s; int xl, yl, xs, ys; cin>>xl>>yl>>xs>>ys; vector<point> v; v.push_back({xs, ys}); int x = xs, y = ys; for(int i = 0; i < s.size(); i++) { if(s[i] == 'L') x--; if(s[i] == 'R') x++; if(s[i] == 'F') y++; if(s[i] == 'B') y--; v.push_back({x, y}); } int dx = x - xs; int dy = y - ys; int rmax = 0, rmin = 2e18; for(auto it : v) { rmax = max(rmax, dist(it.x, it.y, xl, yl)); rmax = max(rmax, dist(it.x + (k - 1) * dx, it.y + (k - 1) * dy, xl, yl)); int st = 2, dr = k, rez = 1; while(st <= dr) { int mij = (st + dr) / 2; int d1 = dist(it.x + (mij - 1) * dx, it.y + (mij - 1) * dy, xl, yl); int d2 = dist(it.x + (mij - 2) * dx, it.y + (mij - 2) * dy, xl, yl); if(d1 - d2 <= 0) rez = mij, st = mij + 1; else dr = mij - 1; } rmin = min(rmin, dist(it.x + (rez - 1) * dx, it.y + (rez - 1) * dy, xl, yl)); } cout<<fixed<<setprecision(12); cout<<(ld)sqrt(rmin)<<" "<<(ld)sqrt(rmax); return 0; }

Compilation message (stderr)

expgorl.cpp: In function 'int main()':
expgorl.cpp:30:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i = 0; i < s.size(); i++)
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...