fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. const int N = 1e5 + 10;
  5. ll a[N], x[N], y[N], dist[N];
  6. int closestPair(vector<pair<ll, ll> > v){
  7. int n = v.size();
  8. sort(v.begin(), v.end());
  9. set<pair<ll, ll> > s;
  10. ll best_dist = LLONG_MAX;
  11. int j = 0;
  12. for(int i = 0; i < n; i++){
  13. ll d = ceil(sqrtl(best_dist));
  14. while(v[i].first - v[j].first >= best_dist){
  15. s.erase({v[j].second, v[j].first});
  16. j++;
  17. }
  18. auto it1 = s.lower_bound({v[i].second - d, v[i].first});
  19. auto it2 = s.upper_bound({v[i].second + d, v[i].first});
  20. for(auto it = it1; it != it2; it++){
  21. ll dx = v[i].first - (it -> second);
  22. ll dy = v[i].second - (it -> first);
  23. best_dist = min(best_dist, dx * dx + dy * dy);
  24. }
  25. s.insert({v[i].second, v[i].first});
  26. }
  27. return best_dist;
  28. }
  29. int main(){
  30. int n;
  31. cin >> n;
  32. vector<pair<ll, ll> > v;
  33. for(int i = 1; i <= n; i++){
  34. cin >> x[i];
  35. }
  36. for(int i = 1; i <= n; i++){
  37. cin >> y[i];
  38. if(i != 1)
  39. dist[i] = dist[i - 1] + ((abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) * ((i & 1) ? -1 : 1));
  40. }
  41. for(int i = 1; i <= n; i++){
  42. cin >> a[i];
  43. a[i] += a[i - 1];
  44. v.push_back({dist[i], a[i]});
  45. }
  46. cout << closestPair(v);
  47. return 0;
  48. }
  49.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.7/py_compile.py", line 143, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./prog.py", line 3
    using namespace std;
                  ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.7/py_compile.py", line 147, in compile
    raise py_exc
py_compile.PyCompileError:   File "./prog.py", line 3
    using namespace std;
                  ^
SyntaxError: invalid syntax

stdout
Standard output is empty