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

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr char newl = '\\n';

constexpr double ticks_per_sec = 2800000000;
constexpr double ticks_per_sec_inv = 1.0 / ticks_per_sec;
inline double rdtsc() { // in seconds
  uint32_t lo, hi;
  asm volatile("rdtsc" : "=a"(lo), "=d"(hi));
  return (((uint64_t)hi << 32) | lo) * ticks_per_sec_inv;
}
constexpr double TLE = 3; // sec
constexpr double time_limit = TLE * 0.98;

unsigned int randxor() {
  static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
  unsigned int t;
  t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

template <typename hoge> void my_shuffle(vector<hoge> &v) {
  int sz = v.size();
  for (int i = sz - 1; i >= 1; i--) {
    swap(v[i], v[randxor() % (i + 1)]);
  }
}

// 定数
constexpr int CONTEST_NUM = 26;

// 入力
constexpr int D = 365;
array<int, CONTEST_NUM> c;
array<array<int, CONTEST_NUM>, D> s;

ll calcScore(const array<int, D> &t) {
  ll score = 0;
  array<int, CONTEST_NUM> lasts{};

  for (int i = 0; i < D; i++) {
    lasts[t[i]] = i + 1;
    score += s[i][t[i]];

    for (int j = 0; j < CONTEST_NUM; j++) {
      score -= c[j] * (i + 1 - lasts[j]);
    }

    cout << score << newl;
  }
  return score;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  {
    int dummy;
    cin >> dummy;

    for (int i = 0; i < CONTEST_NUM; i++) {
      cin >> c[i];
    }

    for (int i = 0; i < D; i++) {
      for (int j = 0; j < CONTEST_NUM; j++) {
        cin >> s[i][j];
      }
    }
  }

  array<int, D> t;
  for (int i = 0; i < D; i++) {
    cin >> t[i];
    --t[i];
  }

  calcScore(t);
  // cout << calcScore(t) << newl;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr char newl = '\\n';

constexpr double ticks_per_sec = 2800000000;
constexpr double ticks_per_sec_inv = 1.0 / ticks_per_sec;
inline double rdtsc() { // in seconds
  uint32_t lo, hi;
  asm volatile("rdtsc" : "=a"(lo), "=d"(hi));
  return (((uint64_t)hi << 32) | lo) * ticks_per_sec_inv;
}
constexpr double TLE = 3; // sec
constexpr double time_limit = TLE * 0.98;

unsigned int randxor() {
  static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
  unsigned int t;
  t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

template <typename hoge> void my_shuffle(vector<hoge> &v) {
  int sz = v.size();
  for (int i = sz - 1; i >= 1; i--) {
    swap(v[i], v[randxor() % (i + 1)]);
  }
}

// 定数
constexpr int CONTEST_NUM = 26;

// 入力
constexpr int D = 5;
array<int, CONTEST_NUM> c;
array<array<int, CONTEST_NUM>, D> s;

ll calcScore(const array<int, D> &t) {
  ll score = 0;
  array<int, CONTEST_NUM> lasts{};

  for (int i = 0; i < D; i++) {
    lasts[t[i]] = i + 1;
    score += s[i][t[i]];

    for (int j = 0; j < CONTEST_NUM; j++) {
      score -= c[j] * (i + 1 - lasts[j]);
    }

    cout << score << newl;
  }
  return score;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  {
    int dummy;
    cin >> dummy;

    for (int i = 0; i < CONTEST_NUM; i++) {
      cin >> c[i];
    }

    for (int i = 0; i < D; i++) {
      for (int j = 0; j < CONTEST_NUM; j++) {
        cin >> s[i][j];
      }
    }
  }

  array<int, D> t;
  for (int i = 0; i < D; i++) {
    cin >> t[i];
    --t[i];
  }

  calcScore(t);
  // cout << calcScore(t) << newl;

  return 0;
}