alexjercan/bugnet huggingface dataset:
Problem p02619 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;
typedef long long ll;

const int nc = 26;
int D;
ll c[40], t[400];
ll s[400][40];

void scoring() {
  vector<int> last(nc + 10, -1);

  long long sat = 0;

  for (ll d = 0; d < D; d++) {
    last[t[d]] = d;

    for (int i = 0; i < nc; i++) {
      sat -= c[i] * (d - last[i]);
    }
    sat += s[d][t[d]];
    cout << sat << endl;
  }
}

int main() {
  cin >> D;

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

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

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

  scoring();

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

int D, nc = 26;
vector<int> c(nc + 10), t(nc + 10);
vector<vector<int>> s;

void scoring(vector<int> &v) {
  vector<int> last(nc + 10, 0);

  int sat = 0;

  for (int d = 1; d <= D; d++) {
    last[t[d]] = d;

    for (int i = 1; i <= nc; i++) {
      sat -= c[i] * (d - last[i]);
    }
    sat += s[d][t[d]];
    v[d] = sat;
  }
}

int main() {
  cin >> D;

  s.resize(D + 10);

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

  for (int i = 1; i <= D; i++) {
    s[i].resize(nc + 10);
    for (int j = 1; j <= nc; j++) {
      cin >> s[i][j];
    }
  }

  // for(int i = 1; i <= D; i++){
  //   for(int j = 1; j <= nc; j++){
  //     cout << s[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  for (int i = 1; i <= D; i++) {
    cin >> t[i];
  }

  vector<int> v(D + 10);
  scoring(v);

  for (int i = 1; i <= D; i++) {
    cout << v[i] << endl;
  }

  return 0;
}
Problem p02619 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  long d;
  cin >> d;
  vector<long> c(26);
  rep(i, 26) { cin >> c.at(i); }
  vector<vector<long>> s(d, vector<long>(26));
  rep(i, d) {
    rep(j, 26) { cin >> s[i][j]; }
  }
  vector<long> t(d);
  rep(i, d) {
    cin >> t[i];
    t[i]--;
  }
  vector<long> ch(26);
  long tot = 0;
  rep(i, d) {

    ch[t[i]] = i + 1;
    long mi = 0;
    rep(j, 26) {
      if (j != t[i]) {
        mi += c[j] * (i + 1 - ch[j]);
      }
    }
    tot += s[i][t[i]] - mi;
    cout << tot << endl;
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  long d;
  cin >> d;
  vector<long> c(26);
  rep(i, 26) { cin >> c.at(i); }
  vector<vector<long>> s(d, vector<long>(26));
  rep(i, d) {
    rep(j, 26) { cin >> s[i][j]; }
  }
  vector<long> t(26);
  rep(i, 26) { cin >> t[i]; }
  vector<long> ch(26);
  long tot = 0;
  rep(i, d) {

    ch[t[i] - 1] = i + 1;
    long mi = 0;
    rep(j, 26) {
      if (j != t[i] - 1) {
        mi += c[j] * (i + 1 - ch[j]);
      }
    }
    tot += s[i][t[i] - 1] - mi;
    cout << tot << endl;
  }
}
Problem p02619 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;
using pint = pair<int, int>;

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;
}

int main() {
  int d;
  cin >> d;
  int c[30] = {}, last[30] = {}, s[400][30] = {}, v = 0;
  rep(i, 26) cin >> c[i];

  rep(i, d) rep(j, 26) cin >> s[i][j];

  rep(i, 26) last[i] = 0;

  rep(i, d) {
    int t;
    cin >> t;
    t--;

    v += s[i][t];
    last[t] = i + 1;

    rep(j, 26) {
      if (j == t)
        continue;
      v -= c[j] * (i + 1 - last[j]);
    }
    cout << v << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;
using pint = pair<int, int>;

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;
}

int main() {
  int d;
  cin >> d;
  int c[30], last[30], s[30][30], v = 0;
  rep(i, 26) cin >> c[i];

  rep(i, d) rep(j, 26) cin >> s[i][j];

  rep(i, 26) last[i] = 0;

  rep(i, d) {
    int t;
    cin >> t;
    t--;

    v += s[i][t];
    last[t] = i + 1;

    rep(j, 26) {
      if (j == t)
        continue;
      v -= c[j] * (i + 1 - last[j]);
    }
    cout << v << endl;
  }

  return 0;
}
Problem p02619 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x)                                                             \\
  for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INFLL = 1LL << 60;
const int INF = 1 << 30;
const double PI = acos(-1);
int main() {
  int d;
  cin >> d;
  Vi ans(d, 0);
  Vi c(26, 0);
  rep(i, 26) { cin >> c[i]; }
  VVi s(d, Vi(26, 0));
  rep(i, d) {
    rep(j, 26) { cin >> s[i][j]; }
  }
  rep(i, d) {
    cin >> ans[i];
    ans[i]--;
  }
  ll res = 0LL;
  Vi last(26, 0);
  rep(i, d) {
    res += s[i][ans[i]];
    last[ans[i]] = i + 1;
    rep(j, 26) { res -= c[j] * (i + 1 - last[j]); }
    cout << res << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x)                                                             \\
  for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INFLL = 1LL << 60;
const int INF = 1 << 30;
const double PI = acos(-1);
int main() {
  int d;
  cin >> d;
  Vi ans(d, 0);
  Vi c(26, 0);
  rep(i, 26) { cin >> c[i]; }
  VVi s(d, Vi(26, 0));
  rep(i, d) {
    rep(j, 26) { cin >> s[i][j]; }
  }
  rep(i, d) { cin >> ans[i]; }
  int res = 0;
  Vi last(26, 0);
  rep(i, d) {
    res += s[i][ans[i]];
    last[ans[i]] = i;
    rep(j, 26) { res -= c[j] * (i - last[j]); }
    cout << res << endl;
  }
  return 0;
}
Problem p02619 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "_DEBUG.hpp"
#endif
// #define int long long
const int INF = 1 << 30;

signed main() {

  int D;
  cin >> D;
  vector<int> C(26);
  for (int i = 0; i < 26; i++) {
    cin >> C[i];
  }

  vector<vector<int>> S(D, vector<int>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> S[i][j];
    }
  }

  vector<int> t(D);
  for (int i = 0; i < D; i++) {
    cin >> t[i];
    t[i]--;
  }
  // int m; cin >> m;
  // for(int i = 0; i < m; i++){
  //   int d, q; cin >> d >> q;
  // }

  int res = 0;
  vector<int> L(26, -1);
  for (int i = 0; i < D; i++) {
    res += S[i][t[i]];
    L[t[i]] = i;
    for (int j = 0; j < 26; j++) {
      res -= C[j] * (i - L[j]);
      // cout << C[j] * (i - L[j]) << " ";
    }
    cout << res << endl;
  }

  // int score = -INF;
  // vector<int> ans(D);
  // while(true){
  //   int res = 0;
  //   vector<int> L(26, -1);
  //   vector<int> dp(D);
  //   for(int i = 0; i < D; i++){
  //     int T = dist_T(rnd);
  //     res += S[i][t[i]];
  //     L[t[i]] = i;
  //     for(int j = 0; j < 26; j++){
  //       if(L[j] == -1) continue;
  //       res -= i - L[j];
  //     }
  //     dp[i] = T;
  //   }
  //   if(score < res){
  //     score = res;
  //     ans = dp;
  //   }

  //   clock_t end = clock();
  //   const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
  //   1000.0;
  //   //printf("time %lf[ms]\\n", time);
  //   if(time >= 1900) break;
  //   //cout << dp << " " << res << endl;
  // }

  // for(int p : ans){
  //   cout << p << endl;
  // }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "_DEBUG.hpp"
#endif
// #define int long long
const int INF = 1 << 30;

signed main() {

  int D;
  cin >> D;
  vector<int> C(26);
  for (int i = 0; i < 26; i++) {
    cin >> C[i];
  }

  vector<vector<int>> S(D, vector<int>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> S[i][j];
    }
  }

  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> t;
  }

  random_device seed_gen;
  mt19937_64 rnd(seed_gen());
  uniform_int_distribution<int> dist_T(1, 26);
  clock_t start = clock();

  int score = -INF;
  vector<int> ans(D);
  while (true) {
    int res = 0;
    vector<int> L(26, -1);
    vector<int> dp(D);
    for (int i = 0; i < D; i++) {
      int T = dist_T(rnd);
      res += S[i][T - 1];
      L[T - 1] = i;
      for (int j = 0; j < 26; j++) {
        if (L[j] == -1)
          continue;
        res -= i - L[j];
      }
      dp[i] = T;
    }
    if (score < res) {
      score = res;
      ans = dp;
    }

    clock_t end = clock();
    const double time =
        static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    // printf("time %lf[ms]\\n", time);
    if (time >= 1999)
      break;
    // cout << dp << " " << res << endl;
  }

  for (int p : ans) {
    cout << p << endl;
  }

  return 0;
}
Problem p02619 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int D;
  cin >> D;
  vector<int> c(27, 0);
  rep(j, 26) cin >> c[j + 1];
  int s[D + 1][27];
  rep(i, D) {
    rep(j, 26) { cin >> s[i + 1][j + 1]; }
  }
  vector<int> t(D + 1, 0);
  rep(i, D) cin >> t[i + 1];

  int ans = 0;
  vector<int> lastday(27, 0);

  for (int day = 1; day <= D; day++) {
    ans += s[day][t[day]];
    lastday[t[day]] = day;
    for (int j = 1; j <= 26; j++) {
      ans -= c[j] * (day - lastday[j]);
    }
    cout << ans << endl;
  }

  // rep(i, 365){
  //     cout << (i % 26) + 1 << endl;
  // }

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int D;
  cin >> D;
  vector<int> c(30, 0);
  rep(j, 26) cin >> c[j + 1];
  int s[D + 4][30];
  rep(i, D) {
    rep(j, 26) { cin >> s[i + 1][j + 1]; }
  }
  vector<int> t(30, 0);
  rep(i, D) cin >> t[i + 1];

  ll ans = 0;
  vector<int> lastday(27, 0);

  for (int day = 1; day <= D; day++) {
    ans += s[day][t[day]];
    lastday[t[day]] = day;
    for (int j = 1; j <= 26; j++) {
      ans -= c[j] * (day - lastday[j]);
    }
    cout << ans << endl;
  }

  // rep(i, 365){
  //     cout << (i % 26) + 1 << endl;
  // }

  return 0;
}
Problem p02619 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define N_CONTEST (26)
#define N_DAY (365)

static void get_input(int &D, vector<int> &c, vector<vector<int>> &s) {
  cin >> D;
  assert(D == N_DAY);
  for (int i = 1; i <= N_CONTEST; i++) {
    cin >> c.at(i);
  }
  for (int i = 1; i <= N_DAY; i++) {
    for (int j = 1; j <= N_CONTEST; j++) {
      cin >> s.at(i).at(j);
    }
  }
}

static long long calc_score(vector<int> &c, vector<vector<int>> &s,
                            vector<int> &t) {
  vector<int> last(N_CONTEST + 1, 0);

  long long score = 0;

  for (int d = 1; d <= N_DAY; d++) {
    score += s.at(d).at(t.at(d));
    last.at(t.at(d)) = d;
    for (int con = 1; con <= N_CONTEST; con++) {
      score -= c.at(con) * (d - last.at(con));
    }
    cout << score << endl;
  }

  return score;
}

int main(void) {
  int D;
  vector<int> c(N_CONTEST + 1);
  vector<vector<int>> s(N_DAY + 1, vector<int>(N_CONTEST + 1, 0));

  get_input(D, c, s);

  //    for ( int i = 0; i < N_DAY; i++ ) {
  //        cout << i % 26 + 1 << endl;
  //    }

  vector<int> t(N_DAY + 1, 0);
  for (int i = 1; i <= N_DAY; i++) {
    cin >> t.at(i);
  }

  calc_score(c, s, t);

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define N_CONTEST (26)
#define N_DAY (5)

static void get_input(int &D, vector<int> &c, vector<vector<int>> &s) {
  cin >> D;
  assert(D == N_DAY);
  for (int i = 1; i <= N_CONTEST; i++) {
    cin >> c.at(i);
  }
  for (int i = 1; i <= N_DAY; i++) {
    for (int j = 1; j <= N_CONTEST; j++) {
      cin >> s.at(i).at(j);
    }
  }
}

static long long calc_score(vector<int> &c, vector<vector<int>> &s,
                            vector<int> &t) {
  vector<int> last(N_CONTEST + 1, 0);

  long long score = 0;

  for (int d = 1; d <= N_DAY; d++) {
    score += s.at(d).at(t.at(d));
    last.at(t.at(d)) = d;
    for (int con = 1; con <= N_CONTEST; con++) {
      score -= c.at(con) * (d - last.at(con));
    }
    cout << score << endl;
  }

  return score;
}

int main(void) {
  int D;
  vector<int> c(N_CONTEST + 1);
  vector<vector<int>> s(N_DAY + 1, vector<int>(N_CONTEST + 1, 0));

  get_input(D, c, s);

  //    for ( int i = 0; i < N_DAY; i++ ) {
  //        cout << i % 26 + 1 << endl;
  //    }

  vector<int> t(N_DAY + 1, 0);
  for (int i = 1; i <= N_DAY; i++) {
    cin >> t.at(i);
  }

  calc_score(c, s, t);

  return 0;
}
Problem p02619 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
  int D;
  cin >> D;

  vector<int> c(26);
  rep(i, 26) { cin >> c[i]; }

  vector<vector<int>> s(D, vector<int>(26));
  rep(d, D) {
    rep(i, 26) { cin >> s[d][i]; }
  }

  vector<int> t(D);
  rep(i, D) {
    cin >> t[i];
    t[i] -= 1;
  }

  vector<int> last(26);
  vector<int> v(D);
  int sat = 0;

  rep(d, D) {
    last[t[d]] = d + 1;

    int desc = 0;
    rep(i, 26) { desc += c[i] * (d + 1 - last[i]); }
    // cout <<s[d][t[d]]<<endl;
    // cout << desc << endl;

    if (d == 0) {
      v[d] = s[d][t[d]] - desc;
    } else {
      v[d] = v[d - 1] + s[d][t[d]] - desc;
    }

    cout << v[d] << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
  int D;
  cin >> D;

  vector<int> c(26);
  rep(i, 26) { cin >> c[i]; }

  vector<vector<int>> s(D, vector<int>(26));
  rep(d, D) {
    rep(i, 26) { cin >> s[d][i]; }
  }

  vector<int> t(D);
  rep(i, D) { cin >> t[i]; }

  vector<int> last(26);
  vector<int> v(D);
  int sat = 0;

  rep(d, D) {
    last[t[d]] = d + 1;

    int desc = 0;
    rep(i, 26) { desc += c[i] * (d + 1 - last[i]); }

    sat = sat + s[d][t[d]] - desc;

    cout << sat << endl;
  }
  return 0;
}
Problem p02619 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int D;
vector<int> c(26 + 1);
vector<vector<int>> s;

int compute_score(vector<int> t) {
  vector<vector<int>> last(D + 1, vector<int>(26 + 1, 0));
  int ans = 0;
  for (int d = 1; d <= D; d++) {
    last[d][t[d]] = d;
    ans += s[d][t[d]];
    for (int i = 1; i <= 26; i++) {
      if (i == t[d])
        continue;
      last[d][i] = last[d - 1][i];
      ans -= c[i] * (d - last[d][i]);
    }
    cout << ans << endl;
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin >> D;
  s.assign(D + 1, vector<int>(26 + 1, 0));
  for (int i = 1; i <= 26; i++)
    cin >> c[i];
  for (int d = 1; d <= D; d++)
    for (int i = 1; i <= 26; i++)
      cin >> s[d][i];
  vector<int> t(D + 1);
  for (int d = 1; d <= D; d++)
    cin >> t[d];
  compute_score(t);
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int D;
vector<int> c(26 + 1);
vector<vector<int>> s;

int compute_score(vector<int> t) {
  vector<vector<int>> last(D + 1, vector<int>(26 + 1, 0));
  int ans = 0;
  for (int d = 1; d <= D; d++) {
    last[d][t[d]] = d;
    ans += s[d][t[d]];
    for (int i = 1; i <= 26; i++) {
      if (i == t[d])
        continue;
      last[d][i] = last[d - 1][i];
      ans -= c[i] * (d - last[d][i]);
    }
    cout << ans << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin >> D;
  s.assign(D + 1, vector<int>(26 + 1, 0));
  for (int i = 1; i <= 26; i++)
    cin >> c[i];
  for (int d = 1; d <= D; d++)
    for (int i = 1; i <= 26; i++)
      cin >> s[d][i];
  vector<int> t(D + 1);
  for (int d = 1; d <= D; d++)
    cin >> t[d];
  compute_score(t);
}
Problem p02619 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

constexpr int N = 26;
constexpr int D = 365;

signed main() {
  int tt;
  cin >> tt;
  int c[N];
  rep(i, N) { cin >> c[i]; }
  int s[D][N];
  rep(i, D) {
    rep(j, N) { cin >> s[i][j]; }
  }
  int t[D];
  rep(i, D) {
    cin >> t[i];
    t[i]--;
  }
  int last[N];
  fill(last, last + N, -1);
  int ans = 0;
  rep(i, D) {
    last[t[i]] = i;
    ans += s[i][t[i]];
    rep(j, N) { ans -= c[j] * (i - last[j]); }
    cout << ans << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

constexpr int N = 26;
constexpr int D = 365;

signed main() {
  int tt;
  cin >> tt;
  int c[N];
  rep(i, N) { cin >> c[i]; }
  int s[D][N];
  rep(i, D) {
    rep(j, N) { cin >> s[i][j]; }
  }
  int t[D];
  rep(i, D) {
    cin >> t[i];
    t[i]--;
  }
  int last[N];
  fill(last, last + N, -1);
  int ans = 0;
  rep(i, D) {
    last[i] = t[i];
    ans += s[i][t[i]];
    rep(j, N) { ans -= c[j] * (i - last[j]); }
    cout << ans << endl;
  }
  return 0;
}
Problem p02619 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main() {
  ll D;
  cin >> D;
  vector<ll> c(26), t(D), last(26, -1);
  vector<vector<ll>> s(365, vector<ll>(26));
  rep(i, 0, 26) cin >> c[i];
  rep(i, 0, D) { rep(j, 0, 26) cin >> s[i][j]; }
  rep(i, 0, D) {
    cin >> t[i];
    t[i]--;
  }
  ll res = 0;
  rep(d, 0, D) {
    res += s[d][t[d]];
    last[t[d]] = d;
    rep(j, 0, 26) { res -= c[j] * (d - last[j]); }
    cout << res << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main() {
  ll D;
  cin >> D;
  vector<ll> c(26), t(26), last(26, -1);
  vector<vector<ll>> s(365, vector<ll>(26));
  rep(i, 0, 26) cin >> c[i];
  rep(i, 0, D) { rep(j, 0, 26) cin >> s[i][j]; }
  rep(i, 0, D) {
    cin >> t[i];
    t[i]--;
  }
  ll res = 0;
  rep(d, 0, D) {
    res += s[d][t[d]];
    last[t[d]] = d;
    rep(j, 0, 26) { res -= c[j] * (d - last[j]); }
    cout << res << endl;
  }

  return 0;
}