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

#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
// cout<<setprecision(20)
const llint mod = 1000000007;
const llint big = 2.19e15 + 1;
const long double pai = 3.141592653589793238462643383279502884197;
const long double eps = 1e-15;
template <class T, class U> void mineq(T &a, U b) {
  if (a > b) {
    a = b;
  }
}
template <class T, class U> void maxeq(T &a, U b) {
  if (a < b) {
    a = b;
  }
}
llint gcd(llint a, llint b) {
  if (a % b == 0) {
    return b;
  } else
    return gcd(b, a % b);
}
llint lcm(llint a, llint b) { return a / gcd(a, b) * b; }
template <class T> void SO(T &ve) { sort(ve.begin(), ve.end()); }
template <class T> void REV(T &ve) { reverse(ve.begin(), ve.end()); }
int LBI(vector<lldo> &ar, lldo in) {
  return lower_bound(ar.begin(), ar.end(), in) - ar.begin();
}
int UBI(vector<lldo> &ar, lldo in) {
  return upper_bound(ar.begin(), ar.end(), in) - ar.begin();
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, K, X, i, j;
  cin >> n >> K >> X;
  mineq(n, 10000);
  // static llint cp[2505][10005]={0};
  static llint dp[2505][10005] = {0};
  static llint ep[2505][10005] = {0};
  // 左側の残り時間,駅間,の累積WA,dpなら右=左-1,epなら右=左 cpなら片方のみ
  // これを前計算
  ep[0][1] = 1;
  for (j = 2; j <= n; j++) {
    ep[0][j] = 2;
  }
  for (i = 1; i <= X; i++) { // dp
    dp[i][1] = 1;
    ep[i][1] = 1;
    for (j = 1; j <= n; j++) {
      dp[i][j + 1] =
          (mod + dp[i][j] + ep[i - 1][j] - ep[i - 1][max(0, j - i - i)]) % mod;
    } // 駅間
    for (j = 1; j <= n; j++) {
      ep[i][j + 1] =
          (mod + ep[i][j] + dp[i][j] - dp[i][max(0, j - i - i)]) % mod;
      if (j == i + i + 1) {
        ep[i][j + 1]++;
      }
    } // 駅間
    /*for(j=1;j<=n+1;j++){cerr<<dp[i][j]<<" ";}
    cerr<<endl;
    for(j=1;j<=n+1;j++){cerr<<ep[i][j]<<" ";}
    cerr<<endl;*/
  }
  llint ans = 1, mae;
  cin >> mae;
  for (i = 0; i < K - 1; i++) {
    int s;
    cin >> s;
    ans *= (mod + dp[X - i][1 + s - mae] - dp[X - i][s - mae]);
    ans %= mod;
    mae = s;
  }
  cout << ans << endl;
  return 0;
}


Error: 127
/tmp/af6dc7a1-01af-46aa-aa23-41547c9455b1.out: error while loading shared libraries: libc.so.6: failed to map segment from shared object


Fixed submission:

#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
// cout<<setprecision(20)
const llint mod = 1000000007;
const llint big = 2.19e15 + 1;
const long double pai = 3.141592653589793238462643383279502884197;
const long double eps = 1e-15;
template <class T, class U> void mineq(T &a, U b) {
  if (a > b) {
    a = b;
  }
}
template <class T, class U> void maxeq(T &a, U b) {
  if (a < b) {
    a = b;
  }
}
llint gcd(llint a, llint b) {
  if (a % b == 0) {
    return b;
  } else
    return gcd(b, a % b);
}
llint lcm(llint a, llint b) { return a / gcd(a, b) * b; }
template <class T> void SO(T &ve) { sort(ve.begin(), ve.end()); }
template <class T> void REV(T &ve) { reverse(ve.begin(), ve.end()); }
int LBI(vector<lldo> &ar, lldo in) {
  return lower_bound(ar.begin(), ar.end(), in) - ar.begin();
}
int UBI(vector<lldo> &ar, lldo in) {
  return upper_bound(ar.begin(), ar.end(), in) - ar.begin();
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, K, X, i, j;
  cin >> n >> K >> X;
  static llint dp[2501][2501] = {0};
  static llint ep[2501][2501] = {0};
  // 左側の残り時間,駅間,の累積WA,dpなら右=左-1,epなら右=左
  // これを前計算
  for (j = 2; j <= n; j++) {
    ep[0][j] = 1;
  }
  for (i = 1; i <= X; i++) { // dp
    dp[i][1] = 1;
    ep[i][1] = 1;
    for (j = 2; j <= n + 1; j++) {
      dp[i][j] = (mod + dp[i][j - 1] + ep[i - 1][j - 1] -
                  ep[i - 1][max(0, j - i - i - 1)]) %
                 mod;
    } // 駅間
    for (j = 2; j <= n + 1; j++) {
      ep[i][j] =
          (mod + ep[i][j - 1] + dp[i][j - 1] - dp[i][max(0, j - i - i - 1)]) %
          mod;
    } // 駅間
    // for(j=1;j<=n+1;j++){cerr<<dp[i][j]<<" ";}
    // cerr<<endl;
    // for(j=1;j<=n+1;j++){cerr<<ep[i][j]<<" ";}
    // cerr<<endl;
  }
  llint ans = 1, mae;
  cin >> mae;
  for (i = 0; i < K - 1; i++) {
    int s;
    cin >> s;
    ans *= (mod + ep[X - i][1 + s - mae] - ep[X - i][s - mae]);
    ans %= mod;
    mae = s;
  }
  cout << ans << endl;
  return 0;
}