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

#include <bits/stdc++.h>
#pragma GCC optimize("O2,unroll-loops")
// #pragma GCC optimize("no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr << #x << '=' << (x) << endl;
#define debugp(x)                                                              \\
  cerr << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define debug2(x, y)                                                           \\
  cerr << "{" << #x << ", " << #y << "} = {" << (x) << ", " << (y) << "}"      \\
       << endl;
#define debugv(v)                                                              \\
  {                                                                            \\
    cerr << #v << " : ";                                                       \\
    for (auto x : v)                                                           \\
      cerr << x << ' ';                                                        \\
    cerr << endl;                                                              \\
  }
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout << x << '\\n', 0;

const int inf = 1000000010;
const ll INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 200010, T = 55;

ll ans; // :))
int n, m, k, u, v, x, y, t, a, b;
pii A[MAXN];
int cnt[T][T];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    ld shit;
    cin >> shit;
    ll x = round(shit * 1000000000);
    while (x % 2 == 0)
      A[i].first++, x /= 2;
    while (x % 5 == 0)
      A[i].second++, x /= 5;
    cnt[A[i].first][A[i].second]++;
    //		debugp(A[i])
    if (min(A[i].first, A[i].second) >= 9)
      ans--;
  }
  for (int i = T - 2; ~i; i--)
    for (int j = T - 2; ~j; j--)
      cnt[i][j] += cnt[i + 1][j] + cnt[i][j + 1] - cnt[i + 1][j + 1];

  for (int i = 1; i <= n; i++)
    ans += cnt[max(0, 18 - A[i].first)][max(0, 18 - A[i].second)];
  ans /= 2;
  cout << ans << "\\n";

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#pragma GCC optimize("O2,unroll-loops")
// #pragma GCC optimize("no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr << #x << '=' << (x) << endl;
#define debugp(x)                                                              \\
  cerr << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define debug2(x, y)                                                           \\
  cerr << "{" << #x << ", " << #y << "} = {" << (x) << ", " << (y) << "}"      \\
       << endl;
#define debugv(v)                                                              \\
  {                                                                            \\
    cerr << #v << " : ";                                                       \\
    for (auto x : v)                                                           \\
      cerr << x << ' ';                                                        \\
    cerr << endl;                                                              \\
  }
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout << x << '\\n', 0;

const int inf = 1000000010;
const ll INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, T = 55;

ll ans; // :))
int n, m, k, u, v, x, y, t, a, b;
pii A[MAXN];
int cnt[T][T];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    ld shit;
    cin >> shit;
    ll x = round(shit * 1000000000);
    while (x % 2 == 0)
      A[i].first++, x /= 2;
    while (x % 5 == 0)
      A[i].second++, x /= 5;
    cnt[A[i].first][A[i].second]++;
    //		debugp(A[i])
    if (min(A[i].first, A[i].second) >= 9)
      ans--;
  }
  for (int i = T - 2; ~i; i--)
    for (int j = T - 2; ~j; j--)
      cnt[i][j] += cnt[i + 1][j] + cnt[i][j + 1] - cnt[i + 1][j + 1];

  for (int i = 1; i <= n; i++)
    ans += cnt[max(0, 18 - A[i].first)][max(0, 18 - A[i].second)];
  ans /= 2;
  cout << ans << "\\n";

  return 0;
}