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

#include <bits/stdc++.h>
#define drep(i, cc, n) for (int i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define drrep(i, cc, n) for (int i = (cc); i >= (n); --i)
#define rrep(i, n) drrep(i, 0, n - 1)
#define sz(s) (int)(s.size())
#define vecprint(v)                                                            \\
  rep(i, v.size()) if (i == 0) cout << v[i];                                   \\
  else cout << " " << v[i];                                                    \\
  cout << endl;
#define arrprint(v, n)                                                         \\
  rep(i, n) if (i == 0) cout << v[i];                                          \\
  else cout << " " << v[i];                                                    \\
  cout << endl;
#define matprint(v, n, m)                                                      \\
  rep(i, n) {                                                                  \\
    rep(j, m) { cout << v[i][j] << " "; }                                      \\
    cout << endl;                                                              \\
  }
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod = 1000000007;
const int INF = 1001001001;
using ll = long long;
using P = pair<int, int>;
template <typename T>
using priority_queue_rev =
    priority_queue<T, vector<T>, greater<T>>; // 小さいものから取り出す

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t;
vector<int> last(26, -1);

ll score() {
  ll res = 0;
  rep(i, d) {
    res += s[i][t[i]];
    last[t[i]] = i;
    rep(j, 26) res -= c[i] * (i - last[j]);
  }
  return res;
}

int main() {
  cin >> d;
  rep(i, 26) cin >> c[i];
  s.resize(d);
  rep(i, d) s[i].resize(26);
  rep(i, d) rep(j, 26) cin >> s[i][j];
  t.resize(d);
  rep(i, d) t[i] = i % 26;

  // cout << score() << endl;
  rep(i, d) cout << t[i] + 1 << endl;

  // cout << ans << endl;
  //  printf("%.10f\\n",ans);

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define drep(i, cc, n) for (int i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define drrep(i, cc, n) for (int i = (cc); i >= (n); --i)
#define rrep(i, n) drrep(i, 0, n - 1)
#define sz(s) (int)(s.size())
#define vecprint(v)                                                            \\
  rep(i, v.size()) if (i == 0) cout << v[i];                                   \\
  else cout << " " << v[i];                                                    \\
  cout << endl;
#define arrprint(v, n)                                                         \\
  rep(i, n) if (i == 0) cout << v[i];                                          \\
  else cout << " " << v[i];                                                    \\
  cout << endl;
#define matprint(v, n, m)                                                      \\
  rep(i, n) {                                                                  \\
    rep(j, m) { cout << v[i][j] << " "; }                                      \\
    cout << endl;                                                              \\
  }
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod = 1000000007;
const int INF = 1001001001;
using ll = long long;
using P = pair<int, int>;
template <typename T>
using priority_queue_rev =
    priority_queue<T, vector<T>, greater<T>>; // 小さいものから取り出す

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t;
vector<int> last(26, -1);

ll score() {
  ll res = 0;
  rep(i, d) {
    res += s[i][t[i]];
    last[t[i]] = i;
    rep(j, 26) res -= c[i] * (i - last[j]);
  }
  return res;
}

int main() {
  cin >> d;
  rep(i, d) cin >> c[i];
  s.resize(d);
  rep(i, d) s[i].resize(26);
  rep(i, d) rep(j, 26) cin >> s[i][j];
  t.resize(d);
  rep(i, d) t[i] = 0;

  // cout << score() << endl;
  rep(i, d) cout << t[i] + 1 << endl;

  // cout << ans << endl;
  //  printf("%.10f\\n",ans);

  return 0;
}