Submission #97165

#TimeUsernameProblemLanguageResultExecution timeMemory
97165KastandaExperiments with Gorlum (IZhO13_expgorl)C++11
100 / 100
7 ms640 KiB
// I do it for the glory #include<bits/stdc++.h> #define pb push_back #define x first #define y second using namespace std; typedef long long ll; const int N = 14004; int n, k, Lx, Ly, Gx, Gy; vector < pair < ll , ll > > A; char S[N]; inline ll Dist(ll a, ll b) { return ((Lx - a) * (Lx - a) + (Ly - b) * (Ly - b)); } int main() { scanf("%d%s%d%d%d%d", &k, &S, &Lx, &Ly, &Gx, &Gy); n = strlen(S); ll nwx = Gx, nwy = Gy; A.pb({nwx, nwy}); for (int i = 0; i < n; i++) { if (S[i] == 'L') nwx --; if (S[i] == 'R') nwx ++; if (S[i] == 'F') nwy ++; if (S[i] == 'B') nwy --; if (S[i] == 'I') continue; A.pb({nwx, nwy}); } ll dfx = nwx - Gx, dfy = nwy - Gy; ll Mn = 7e18, Mx = - Mn; for (int i = 0; i < (int)A.size(); i++) { tie(nwx, nwy) = A[i]; Mx = max(Mx, Dist(nwx, nwy)); Mx = max(Mx, Dist(nwx + dfx * (k - 1), nwy + dfy * (k - 1))); int le = 0, ri = k - 1, md1, md2; while (ri - le > 3) { md1 = (le + le + ri) / 3; md2 = (le + ri + ri) / 3; ll d1 = Dist(nwx + dfx * md1, nwy + dfy * md1); ll d2 = Dist(nwx + dfx * md2, nwy + dfy * md2); if (d1 < d2) ri = md2; else le = md1; } for (; le <= ri; le ++) Mn = min(Mn, Dist(nwx + dfx * le, nwy + dfy * le)); } cout << fixed << setprecision(15); cout << sqrt((long double)Mn) << " " << sqrt((long double)Mx) << endl; return 0; }

Compilation message (stderr)

expgorl.cpp: In function 'int main()':
expgorl.cpp:18:53: warning: format '%s' expects argument of type 'char*', but argument 3 has type 'char (*)[14004]' [-Wformat=]
     scanf("%d%s%d%d%d%d", &k, &S, &Lx, &Ly, &Gx, &Gy);
                               ~~                    ^
expgorl.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%s%d%d%d%d", &k, &S, &Lx, &Ly, &Gx, &Gy);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...