Problem p00717 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef pair<double, double> mypair;
typedef complex<double> point;
#define EPS 1e-6
/*mypair in(){
        int x,y;
        cin>>x>>y;
        return mypair(x,y);
}*/
point make() {
  double x, y;
  cin >> x >> y;
  point c(x, y);
  return c;
}
bool is_arg(double a, double b) {
  point c(-1, 0);
  double pi = 2 * arg(c);
  // cout<<"pi "<<pi<<endl;
  if (abs(a - b) <= EPS)
    return true;
  if (abs(a - b + pi) <= EPS)
    return true;
  if (abs(a - b - pi) <= EPS)
    return true;
  return false;
}

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    n++;
    vector<vector<point>> p(n);
    for (int i = 0; i < n; i++) {
      int m;
      cin >> m;
      for (int j = 0; j < m; j++)
        p[i].push_back(make());
    }
    vector<mypair> origin[2]; // abs,arg
    int size = p[0].size();
    point now1 = p[0][0];
    point now2 = p[0][size - 1];
    for (int j = 1; j < size; j++) {
      point tmp1 = p[0][j] - now1;
      point tmp2 = p[0][size - 1 - j] - now2;
      origin[0].push_back(mypair(abs(tmp1), arg(tmp1)));
      origin[1].push_back(mypair(abs(tmp2), arg(tmp2)));
      now1 = p[0][j];
      now2 = p[0][size - 1 - j];
    }
    vector<vector<mypair>> a(n);
    double arg1 = origin[0][0].second;
    double arg2 = origin[1][0].second;

    /*cout<<"arg "<<arg1<<' '<<arg2<<endl;
    for(int i=0;i<2;i++){
            for(int j=0;j<origin[i].size();j++){
                    cout<<origin[i][j].first<<' '<<origin[i][j].second<<"  ";
            }
            cout<<endl;
    }
    cout<<endl;*/
    for (int i = 1; i < n; i++) {
      point now = p[i][0];
      for (int j = 1; j < p[i].size(); j++) {
        point tmp = p[i][j] - now;
        a[i].push_back(mypair(abs(tmp), arg(tmp)));
        //	cout<<a[i][j-1].first<<' '<<a[i][j-1].second<<"  ";
        now = p[i][j];
      }
      //	cout<<endl;
    }
    vector<int> ans;
    for (int i = 1; i < n; i++) {
      bool flag1 = true, flag2 = true;
      if (p[i].size() != size)
        continue;
      double d1 = a[i][0].second - arg1, d2 = a[i][0].second - arg2;
      for (int j = 0; j < size - 1; j++) {
        if (a[i][j].first == origin[0][j].first &&
            is_arg(a[i][j].second - origin[0][j].second, d1)) {
        } else {
          flag1 = false;
          break;
        }

        /*if(a[i][j].first != origin[0][j].first ||
        a[i][j].second-origin[0][j].second != d1) { flag1 = false; break;
        }*/
      }

      for (int j = 0; j < size - 1; j++) {
        if (a[i][j].first == origin[1][j].first &&
            is_arg(a[i][j].second - origin[1][j].second, d2)) {

        } else {
          flag2 = false;
          break;
        }
        /*if(a[i][j].first != origin[1][j].first ||
        a[i][j].second-origin[1][j].second != d2) { flag2 = false; break;
        }*/
      }
      if (flag1 || flag2)
        ans.push_back(i);
    }
    for (int i = 0; i < ans.size(); i++)
      cout << ans[i] << endl;
    cout << "+++++" << endl;
  }
  return 0;
}


Error: -11

Fixed submission:

#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n, k, t, u, v, l;
  cin >> n >> k >> t >> u >> v >> l;
  vector<int> d(n);
  vector<bool> x(l, false);
  vector<bool> a(l, false);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    x[d[i]] = true;
  }
  int rest = 0;
  int a1 = t * v;
  int amax = a1 * (k + 1);
  // cout<<amax<<endl;
  for (int i = 0; i < l; i++) {
    if (x[i])
      rest += a1;
    if (rest > amax)
      rest = amax;
    if (rest != 0) {
      //		 cout<<rest<<" ";
      rest--;
      a[i] = true;
      //		 cout<<i<<" ";
    }
  }
  int nl = 0, al = 0;
  for (int i = 0; i < l; i++) {
    if (a[i])
      al++;
    else
      nl++;
  }
  //	cout<<al<<" "<<nl<<endl;
  printf("%f\\n", (double)al / v + (double)nl / u);

  return 0;
}