Submission #168893

#TimeUsernameProblemLanguageResultExecution timeMemory
168893abilExperiments with Gorlum (IZhO13_expgorl)C++14
0 / 100
12 ms256 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() //#define int long long using namespace std; const int N = (1e6 + 12); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); int lx, ly; double dist(double x, double y){ return sqrt((x - lx) * (x - lx) + (y - ly) * (y - ly)); } double dist1(double x, double y, double xx, double yy){ return sqrt((x - xx) * (x - xx) + (y - yy) * (y - yy)); } bool check(double x, double y, double xx, double yy){ return dist(xx, yy) >= dist1(xx, yy, x, y); } main() { int k; string s; scanf("%d", &k); cin >> s; double gx, gy; cin >> lx >> ly; cin >> gx >> gy; double inx = gx, iny = gy; double ansmin = dist(gx, gy), ansmax = dist(gx, gy); double ans1 = ansmin, ans2 = ansmax, lastx, lasty; lastx = gx, lasty = gy; for(int j = 0;j < s.size(); j++){ if(s[j] == 'L'){ gx--; } else if(s[j] == 'R'){ gx++; } else if(s[j] == 'F'){ gy++; } else if(s[j] == 'B'){ gy--; } lastx = gx; lasty = gx; } ans1 = min(ans1, dist(lastx, lasty)); if(ans1 == ansmin){ gx = inx, gy = iny; for(int i = 0;i < min(1000, k); i++){ for(int j = 0;j < s.size(); j++){ if(s[j] == 'L'){ gx--; } else if(s[j] == 'R'){ gx++; } else if(s[j] == 'F'){ gy++; } else if(s[j] == 'B'){ gy--; } ansmin = min(ansmin, dist(gx, gy)); } } gx = inx, gy = iny; double xx, yy; if(lastx >= gx){ xx = lastx - gx; } else{ xx = gx - lastx; xx = -xx; } if(lasty >= gy){ yy = lasty - gy; } else{ yy = gy - lasty; yy = -yy; } gx = gx + max(0, k - 1000) * xx; gy = gy + max(0, k - 1000) * yy; for(int i = max(1, k - 1000);i <= k; i++){ for(int j = 0;j < s.size(); j++){ if(s[j] == 'L'){ gx--; } else if(s[j] == 'R'){ gx++; } else if(s[j] == 'F'){ gy++; } else if(s[j] == 'B'){ gy--; } ansmax = max(ansmax, dist(gx, gy)); } } } else{ gx = inx, gy = iny; for(int i = 0;i < min(1000, k); i++){ for(int j = 0;j < s.size(); j++){ if(s[j] == 'L'){ gx--; } else if(s[j] == 'R'){ gx++; } else if(s[j] == 'F'){ gy++; } else if(s[j] == 'B'){ gy--; } ansmax = max(ansmax, dist(gx, gy)); } } gx = inx, gy = iny; double xx, yy; if(lastx >= gx){ xx = lastx - gx; } else{ xx = gx - lastx; xx = -xx; } if(lasty >= gy){ yy = lasty - gy; } else{ yy = gy - lasty; yy = -yy; } gx = gx + max(0, k - 1000) * xx; gy = gy + max(0, k - 1000) * yy; for(int i = max(1, k - 1000);i <= k; i++){ for(int j = 0;j < s.size(); j++){ if(s[j] == 'L'){ gx--; } else if(s[j] == 'R'){ gx++; } else if(s[j] == 'F'){ gy++; } else if(s[j] == 'B'){ gy--; } ansmin = min(ansmin, dist(gx, gy)); } } } cout << fixed << setprecision(9) << ansmin << " " << ansmax; }

Compilation message (stderr)

expgorl.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
expgorl.cpp: In function 'int main()':
expgorl.cpp:42:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j = 0;j < s.size(); j++){
                ~~^~~~~~~~~~
expgorl.cpp:65:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = 0;j < s.size(); j++){
                  ~~^~~~~~~~~~
expgorl.cpp:103:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = 0;j < s.size(); j++){
                  ~~^~~~~~~~~~
expgorl.cpp:126:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = 0;j < s.size(); j++){
                  ~~^~~~~~~~~~
expgorl.cpp:164:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = 0;j < s.size(); j++){
                  ~~^~~~~~~~~~
expgorl.cpp:40:24: warning: unused variable 'ans2' [-Wunused-variable]
  double ans1 = ansmin, ans2 = ansmax, lastx, lasty;
                        ^~~~
expgorl.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &k);
  ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...