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

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define pii pair<int, int> /**/
#define fs first
#define sc second
// #define x first
// #define y second
#define mpr make_pair
#define pb push_back
#define vi vector<int>    /**/
#define vp vector<pii>    /**/
#define si set<int>       /**/
#define sp set<pii>       /**/
#define mii map<int, int> /**/
#define mpi map<pii, int> /**/
#define mip map<int, pii> /**/
#define mpp map<pii, pii> /**/
#define iter iterator
#define all(V) V.begin(), V.end()
#define srt(V) sort(all(V))
#define sau(V) srt(V), V.resize(unique(all(V)) - V.begin())
#define ginit(R, C, val) vector<vi>(R, vi(C, val))
#define deb(V) cout << #V << "=" << V << endl
#define de1(V, ZO, TEND)                                                       \\
  {                                                                            \\
    cout << #V << "=[";                                                        \\
    for (int cmFpbnk9 = ZO; cmFpbnk9 < TEND + ZO; cmFpbnk9++)                  \\
      cout << V[cmFpbnk9] << ",";                                              \\
    cout << "]" << endl;                                                       \\
  }
#define de2(V, ZO, ROW, COLUMN)                                                \\
  {                                                                            \\
    int WIDTH = 1;                                                             \\
    for (int lmssb_ = ZO; lmssb_ < ROW + ZO; lmssb_++) {                       \\
      for (int lmgw = ZO; lmgw < COLUMN + ZO; lmgw++) {                        \\
        int LWIDTH = 0, TVAL = V[lmssb_][lmgw];                                \\
        while (TVAL) {                                                         \\
          LWIDTH++;                                                            \\
          TVAL /= 10;                                                          \\
        }                                                                      \\
        if (V[lmssb_][lmgw] < 0)                                               \\
          WIDTH = max(WIDTH, LWIDTH + 1);                                      \\
        else                                                                   \\
          WIDTH = max(WIDTH, LWIDTH);                                          \\
      }                                                                        \\
    }                                                                          \\
    int TWIDTH = max((int)2, (int)strlen(#V));                                 \\
    cout << #V;                                                                \\
    for (int _23367M = 1; _23367M <= TWIDTH - strlen(#V); _23367M++)           \\
      cout << " ";                                                             \\
    cout << "|";                                                               \\
    for (int lmgw = ZO; lmgw < COLUMN + ZO; lmgw++)                            \\
      cout << setw(WIDTH + 1) << left << lmgw;                                 \\
    cout << endl;                                                              \\
    for (int _23367M = 1; _23367M <= TWIDTH; _23367M++)                        \\
      cout << "-";                                                             \\
    cout << "+";                                                               \\
    for (int _23367M = 1; _23367M <= (WIDTH + 1) * COLUMN; _23367M++)          \\
      cout << "-";                                                             \\
    cout << endl;                                                              \\
    for (int lmssb_ = ZO; lmssb_ < ROW + ZO; lmssb_++) {                       \\
      cout << setw(TWIDTH) << lmssb_ << "|";                                   \\
      for (int lmgw = ZO; lmgw < COLUMN + ZO; lmgw++)                          \\
        cout << setw(WIDTH + 1) << left << V[lmssb_][lmgw];                    \\
      cout << endl;                                                            \\
    }                                                                          \\
  }
#define de3(V, ZO, ROW, COLUMN)                                                \\
  {                                                                            \\
    cout << #V << "[][]=" << endl;                                             \\
    for (int lmssb_ = ZO; lmssb_ < ROW + ZO; lmssb_++) {                       \\
      for (int lmgw = ZO; lmgw < COLUMN + ZO; lmgw++)                          \\
        cout << V[lmssb_][lmgw] << " ";                                        \\
      cout << endl;                                                            \\
    }                                                                          \\
  }

template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &V) {
  is >> V.fs >> V.sc;
  return is;
}

template <typename T> istream &operator>>(istream &is, vector<T> &V) {
  for (int i = 0; i < V.size(); i++)
    is >> V[i];
  return is;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> &V) {
  os << "(" << V.fs << "," << V.sc << ")";
  return os;
}

template <typename T> ostream &operator<<(ostream &os, vector<T> &V) {
  os << "[";
  for (auto i : V)
    os << i << " ";
  os << "]";
  return os;
}

template <typename T> ostream &operator<<(ostream &os, set<T> &V) {
  os << "{";
  for (auto i : V)
    os << i << " ";
  os << "}";
  return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &V) {
  os << "{";
  for (auto i : V)
    os << i << " ";
  os << "}";
  return os;
}

template <typename T> inline void cmin(T &x, T y) {
  if (x > y)
    x = y;
}

template <typename T> inline void cmax(T &x, T y) {
  if (x < y)
    x = y;
}

const int P = 1000000000ll;

int N;
int a[200010];
int cnt[200010][2];
int lt[50][50];

signed main() {
  ios::sync_with_stdio(false);
  //	freopen(".in","r",stdin);
  //	freopen(".out","w",stdout);

  cin >> N;
  for (int i = 1; i <= N; i++) {
    double t;
    cin >> t;
    double m = t * (double)P;
    if (m - (double)floor(m) >= 0.5)
      a[i] = floor(m) + 1;
    else
      a[i] = floor(m);
    int x = a[i];
    while (x % 2 == 0) {
      cnt[i][0]++;
      x /= 2;
    }
    while (x % 5 == 0) {
      cnt[i][1]++;
      x /= 5;
    }
  }
  for (int i = 1; i <= N; i++) {
    lt[cnt[i][0]][cnt[i][1]]++;
  }
  for (int i = 48; i >= 0; i--) {
    for (int j = 48; j >= 0; j--) {
      lt[i][j] += lt[i + 1][j] + lt[i][j + 1] - lt[i + 1][j + 1];
    }
  }
  //	de2(cnt,0,N+1,2);
  //	de2(lt,0,20,20);
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += lt[max(0ll, 18 - cnt[i][0])][max(0ll, 18 - cnt[i][1])];
    if (cnt[i][0] >= 9 && cnt[i][1] >= 9)
      ans--;
  }
  cout << ans / 2 << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define pii pair<int, int> /**/
#define fs first
#define sc second
// #define x first
// #define y second
#define mpr make_pair
#define pb push_back
#define vi vector<int>    /**/
#define vp vector<pii>    /**/
#define si set<int>       /**/
#define sp set<pii>       /**/
#define mii map<int, int> /**/
#define mpi map<pii, int> /**/
#define mip map<int, pii> /**/
#define mpp map<pii, pii> /**/
#define iter iterator
#define all(V) V.begin(), V.end()
#define srt(V) sort(all(V))
#define sau(V) srt(V), V.resize(unique(all(V)) - V.begin())
#define ginit(R, C, val) vector<vi>(R, vi(C, val))
#define deb(V) cout << #V << "=" << V << endl
#define de1(V, ZO, TEND)                                                       \\
  {                                                                            \\
    cout << #V << "=[";                                                        \\
    for (int cmFpbnk9 = ZO; cmFpbnk9 < TEND + ZO; cmFpbnk9++)                  \\
      cout << V[cmFpbnk9] << ",";                                              \\
    cout << "]" << endl;                                                       \\
  }
#define de2(V, ZO, ROW, COLUMN)                                                \\
  {                                                                            \\
    int WIDTH = 1;                                                             \\
    for (int lmssb_ = ZO; lmssb_ < ROW + ZO; lmssb_++) {                       \\
      for (int lmgw = ZO; lmgw < COLUMN + ZO; lmgw++) {                        \\
        int LWIDTH = 0, TVAL = V[lmssb_][lmgw];                                \\
        while (TVAL) {                                                         \\
          LWIDTH++;                                                            \\
          TVAL /= 10;                                                          \\
        }                                                                      \\
        if (V[lmssb_][lmgw] < 0)                                               \\
          WIDTH = max(WIDTH, LWIDTH + 1);                                      \\
        else                                                                   \\
          WIDTH = max(WIDTH, LWIDTH);                                          \\
      }                                                                        \\
    }                                                                          \\
    int TWIDTH = max((int)2, (int)strlen(#V));                                 \\
    cout << #V;                                                                \\
    for (int _23367M = 1; _23367M <= TWIDTH - strlen(#V); _23367M++)           \\
      cout << " ";                                                             \\
    cout << "|";                                                               \\
    for (int lmgw = ZO; lmgw < COLUMN + ZO; lmgw++)                            \\
      cout << setw(WIDTH + 1) << left << lmgw;                                 \\
    cout << endl;                                                              \\
    for (int _23367M = 1; _23367M <= TWIDTH; _23367M++)                        \\
      cout << "-";                                                             \\
    cout << "+";                                                               \\
    for (int _23367M = 1; _23367M <= (WIDTH + 1) * COLUMN; _23367M++)          \\
      cout << "-";                                                             \\
    cout << endl;                                                              \\
    for (int lmssb_ = ZO; lmssb_ < ROW + ZO; lmssb_++) {                       \\
      cout << setw(TWIDTH) << lmssb_ << "|";                                   \\
      for (int lmgw = ZO; lmgw < COLUMN + ZO; lmgw++)                          \\
        cout << setw(WIDTH + 1) << left << V[lmssb_][lmgw];                    \\
      cout << endl;                                                            \\
    }                                                                          \\
  }
#define de3(V, ZO, ROW, COLUMN)                                                \\
  {                                                                            \\
    cout << #V << "[][]=" << endl;                                             \\
    for (int lmssb_ = ZO; lmssb_ < ROW + ZO; lmssb_++) {                       \\
      for (int lmgw = ZO; lmgw < COLUMN + ZO; lmgw++)                          \\
        cout << V[lmssb_][lmgw] << " ";                                        \\
      cout << endl;                                                            \\
    }                                                                          \\
  }

template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &V) {
  is >> V.fs >> V.sc;
  return is;
}

template <typename T> istream &operator>>(istream &is, vector<T> &V) {
  for (int i = 0; i < V.size(); i++)
    is >> V[i];
  return is;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> &V) {
  os << "(" << V.fs << "," << V.sc << ")";
  return os;
}

template <typename T> ostream &operator<<(ostream &os, vector<T> &V) {
  os << "[";
  for (auto i : V)
    os << i << " ";
  os << "]";
  return os;
}

template <typename T> ostream &operator<<(ostream &os, set<T> &V) {
  os << "{";
  for (auto i : V)
    os << i << " ";
  os << "}";
  return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &V) {
  os << "{";
  for (auto i : V)
    os << i << " ";
  os << "}";
  return os;
}

template <typename T> inline void cmin(T &x, T y) {
  if (x > y)
    x = y;
}

template <typename T> inline void cmax(T &x, T y) {
  if (x < y)
    x = y;
}

const int P = 1000000000;

int N;
int a[100010];
int cnt[100010][2];
int lt[30][30];

signed main() {
  ios::sync_with_stdio(false);
  //	freopen(".in","r",stdin);
  //	freopen(".out","w",stdout);

  cin >> N;
  for (int i = 1; i <= N; i++) {
    double t;
    cin >> t;
    a[i] = t * P;
    int x = a[i];
    while (x % 2 == 0) {
      cnt[i][0]++;
      x /= 2;
    }
    while (x % 5 == 0) {
      cnt[i][1]++;
      x /= 5;
    }
  }
  for (int i = 1; i <= N; i++) {
    lt[cnt[i][0]][cnt[i][1]]++;
  }
  for (int i = 28; i >= 0; i--) {
    for (int j = 28; j >= 0; j--) {
      lt[i][j] += lt[i + 1][j] + lt[i][j + 1] - lt[i + 1][j + 1];
    }
  }
  //	de2(cnt,0,N+1,2);
  //	de2(lt,0,20,20);
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += lt[max(0ll, 18 - cnt[i][0])][max(0ll, 18 - cnt[i][1])];
    if (cnt[i][0] >= 9 && cnt[i][1] >= 9)
      ans--;
  }
  cout << ans / 2 << endl;

  return 0;
}