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



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

// defines...
#define ll long long
#define tata return;
#define pb push_back
#define mp make_pair
#define in insert
#define run                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define vec vector<ll>
#define setl set<ll>
#define mapl map<ll, ll>
#define shunno cout << 0 << endl;
#define pi 2 * acos(0.0) 1
#define hobena cout << -1 << endl;

// typedefs...
typedef pair<ll, ll> pll;

// const..
// const ll fx[]={0,1,0,-1};
// const ll fy[]={1,0,-1,0};
const ll mod = 1e9 + 7;

//......Algo.....

/*ll ncr(ll n, ll k)
{
    ll res = 1;


    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
*/
// to remove suffix of a number from a set of string
/*
for(int k=1; k<j.size(); k++)
                if(temp.count(string(j.begin()+k,j.end())))
                                        temp.erase(string(j.begin()+k,j.end()));
 */
ll bigmod(ll base, ll power, ll mod) {
  if (power == 0)
    return 1;
  else if (power % 2) {
    ll p1 = base % mod;
    ll p2 = (bigmod(base, power - 1, mod)) % mod;
    return (p1 * p2) % mod;
  } else {
    ll p = (bigmod(base, power / 2, mod) % mod);
    return (p * p) % mod;
  }
}
ll dp[1000000];
void oka() {
  memset(dp, 0, sizeof dp);
  ll n, i, j, k;
  cin >> n;
  for (i = 1; i <= 100; i++) {
    for (j = 1; j <= 100; j++) {
      for (k = 1; k <= 100; k++) {
        dp[i * i + j * j + k * k + i * j + i * k + j * k]++;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    cout << dp[i] << endl;
  }
}
/*I'll paint it on the walls
     cause I'm the one at fault
    I'll never fight again and
         this is how it ends .*/

int main() {
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  run ll t;
  t = 1;
  // cin>>t;
  while (t--) {

    oka();
  }
}


Error: 0

Fixed submission:



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

// defines...
#define ll long long
#define tata return;
#define pb push_back
#define mp make_pair
#define in insert
#define run                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define vec vector<ll>
#define setl set<ll>
#define mapl map<ll, ll>
#define shunno cout << 0 << endl;
#define pi 2 * acos(0.0) 1
#define hobena cout << -1 << endl;

// typedefs...
typedef pair<ll, ll> pll;

// const..
// const ll fx[]={0,1,0,-1};
// const ll fy[]={1,0,-1,0};
const ll mod = 1e9 + 7;

//......Algo.....

/*ll ncr(ll n, ll k)
{
    ll res = 1;


    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
*/
// to remove suffix of a number from a set of string
/*
for(int k=1; k<j.size(); k++)
                if(temp.count(string(j.begin()+k,j.end())))
                                        temp.erase(string(j.begin()+k,j.end()));
 */
ll bigmod(ll base, ll power, ll mod) {
  if (power == 0)
    return 1;
  else if (power % 2) {
    ll p1 = base % mod;
    ll p2 = (bigmod(base, power - 1, mod)) % mod;
    return (p1 * p2) % mod;
  } else {
    ll p = (bigmod(base, power / 2, mod) % mod);
    return (p * p) % mod;
  }
}
ll dp[1000000];
void oka() {
  memset(dp, 0, sizeof dp);
  ll n, i, j, k;
  cin >> n;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      for (k = 1; k <= n; k++) {
        dp[i * i + j * j + k * k + i * j + i * k + j * k]++;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    cout << dp[i] << endl;
  }
}
/*I'll paint it on the walls
     cause I'm the one at fault
    I'll never fight again and
         this is how it ends .*/

int main() {
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  run ll t;
  t = 1;
  // cin>>t;
  while (t--) {

    oka();
  }
}