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

#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

ll gcd(ll n, ll m) {
  ll tmp;
  while (m != 0) {
    tmp = n % m;
    n = m;
    m = tmp;
  }
  return n;
}

ll lcm(ll n, ll m) {
  return abs(n) / gcd(n, m) * abs(m); // gl=xy
}

using namespace std;

void solve() {
  int n;
  cin >> n;
  map<pair<ll, ll>, ll> cnt;
  vector<pair<ll, ll>> v(n);
  rep(i, n) {
    double num;
    cin >> num;
    ll x = llround(1e9 * num);
    ll two = 0, five = 0;
    while (x % 2 == 0) {
      x /= 2;
      ++two;
    }
    while (x % 5 == 0) {
      x /= 5;
      ++five;
    }
    two -= 9;
    five -= 9;
    cnt[make_pair(two, five)]++;
    v[i] = make_pair(two, five);
  }
  ll ans = 0;
  rep(i, n) {
    ll two = v[i].first;
    ll five = v[i].second;
    cnt[make_pair(two, five)]--;
    for (auto x : cnt) {
      if (two + x.first.first >= 0 && five + x.first.second >= 0) {
        ans += x.second;
      }
    }
  }
  cout << ans << "\\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

ll gcd(ll n, ll m) {
  ll tmp;
  while (m != 0) {
    tmp = n % m;
    n = m;
    m = tmp;
  }
  return n;
}

ll lcm(ll n, ll m) {
  return abs(n) / gcd(n, m) * abs(m); // gl=xy
}

using namespace std;

void solve() {
  int n;
  cin >> n;
  map<pair<ll, ll>, ll> cnt;
  vector<pair<ll, ll>> v(n);
  rep(i, n) {
    double num;
    cin >> num;
    ll x = 1000000000LL * num;
    double y = x / 1000000000.0;
    assert(num == y);
    ll two = 0, five = 0;
    while (x % 2 == 0) {
      x /= 2;
      ++two;
    }
    while (x % 5 == 0) {
      x /= 5;
      ++five;
    }
    two -= 9;
    five -= 9;
    cnt[make_pair(two, five)]++;
    v[i] = make_pair(two, five);
  }
  ll ans = 0;
  rep(i, n) {
    ll two = v[i].first, five = v[i].second;
    cnt[make_pair(two, five)]--;
    for (auto x : cnt) {
      if (two + x.first.first >= 0 && five + x.first.second >= 0) {
        ans += x.second;
      }
    }
  }
  cout << ans << "\\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}