alexjercan/bugnet huggingface dataset:
Problem p02618 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define ll long long

int d = 365;
vector<vector<int>> s(d, vector<int>(26, 0));
vector<ll> c(26);

void init() {
  cin >> d;
  for (int i = 0; i < 26; i++)
    cin >> c[i];
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  return;
}

ll calc(vector<int> out) {
  ll score = 0;
  vector<ll> last(26, 0);
  for (int i = 0; i < out.size(); i++) {
    last[out[i]] = i + 1; // タイプ番号
    // cout << "out[" << i << "] " << out[i] << " ";
    for (int j = 0; j < 26; j++) {
      score -= c[j] * ((i + 1) - last[j]);
    }
    score += s[i][out[i]];
    // cout << "score : " << score << endl;
  }

  for (int i = out.size(); i < d; i++) {
    for (int j = 0; j < 26; j++) {
      score -= c[j] * ((i + 1) - last[j]);
    }
  }
  return score;
}

int main() {
  init();
  vector<int> out;
  ll ans = 0;
  // ll tmp = 0;
  ll max_v = -1;
  for (int i = 0; i < d; i++) {
    // max_v = -100000000000;
    max_v = LLONG_MIN;
    int best = 0;
    for (int j = 0; j < 26; j++) {
      out.push_back(j);
      ll tmp = calc(out);
      if (max_v < tmp) {
        max_v = tmp;
        best = j;
      }
      out.pop_back();
    }
    out.push_back(best);
  }

  for (int i = 0; i < d; i++) {
    cout << out[i] + 1 << endl;
  }
  // cout << max_v << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define ll long long

int d = 365;
vector<vector<int>> s(d + 1, vector<int>(26 + 1, 0));
vector<int> c(26 + 1);

void init() {
  cin >> d;
  for (int i = 1; i <= 26; i++)
    cin >> c[i];
  for (int i = 1; i <= d; i++) {
    for (int j = 1; j <= 26; j++) {
      cin >> s[i][j];
      // cout << s[i][j] << " ";
    }
    // cout << endl;
  }
  return;
}

ll calc(vector<int> out) {
  ll score = 0;
  vector<ll> last(26 + 1, 0);
  cout << out.size() << endl;
  for (int i = 1; i < out.size(); i++) {
    cout << i << endl;
    last[out[i]] = i;
    // cout << "out: " << out[i] << endl;
    // last[out[i]] = i+1; // タイプ番号
    for (int j = 1; j <= 26; j++) {
      score -= c[j] * ((i)-last[j]);
    }
    score += s[i][out[i]];
  }
  // cout << score << endl;
  return score;
}

int main() {
  init();
  vector<int> out;
  out.push_back(-1);
  ll ans = 0;
  ll tmp = 0;
  ll max_v = 0;
  for (int i = 1; i <= d; i++) {
    max_v = -1;
    int best = 0;
    for (int j = 1; j <= 26; j++) {
      out.push_back(j);
      // cout << j << endl;
      tmp = calc(out);
      if (max_v < tmp) {
        max_v = tmp;
        best = j;
      }
      out.pop_back();
    }
    out.push_back(best);
  }

  for (int i = 1; i < out.size(); i++) {
    cout << out[i] << endl;
  }
  cout << max_v << endl;
  // cout << out.size() << endl;
  return 0;
}
Problem p02618 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d, vector<int>(26));

  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  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++) {
    t[i] = i % 26 + 1;
  }

  int m = 10000;
  long long ans = 0;
  while (m--) {
    vector<int> tt(d);
    for (int i = 0; i < d; i++) {
      tt[i] = t[i];
    }
    int dd = m % d, p = (m % 26 + 13) % 26 + 1;
    t[dd] = p;

    long long buf = 0;
    vector<int> last(26, 0);
    for (int i = 0; i < d; i++) {
      buf += s[i][t[i] - 1];
      last[t[i] - 1] = i + 1;
      for (int j = 0; j < 26; j++) {
        buf -= c[j] * (i + 1 - last[j]);
      }
    }

    if (ans < buf)
      ans = buf;
    else {
      for (int i = 0; i < d; i++) {
        t[i] = tt[i];
      }
    }
  }
  // cout << ans << endl;
  for (int i = 0; i < d; i++) {
    cout << t[i] << endl;
  }
}


Error: WA

Fixed submission:

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

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d, vector<int>(26));

  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  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++) {
    t[i] = i + 1;
  }

  int m = 10;
  long long ans = 0;
  while (m--) {
    vector<int> tt(d);
    for (int i = 0; i < d; i++) {
      tt[i] = t[i];
    }
    int dd = m % d, p = (m % 26 + 13) % 26 + 1;
    t[dd] = p;

    long long buf = 0;
    vector<int> last(26, 0);
    for (int i = 0; i < d; i++) {
      buf += s[i][t[i] - 1];
      last[t[i] - 1] = i + 1;
      for (int j = 0; j < 26; j++) {
        buf -= c[j] * (i + 1 - last[j]);
      }
    }

    if (ans < buf)
      ans = buf;
    else {
      for (int i = 0; i < d; i++) {
        t[i] = tt[i];
      }
    }
  }

  cout << ans << endl;
}
Problem p02618 (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;
using P = pair<int, int>;

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(i, d) {
    rep(j, 26) { cin >> s[i][j]; }
  }
  vector<int> t(d);
  rep(i, d) {
    int s_max = 0;
    rep(j, 26) {
      if (s_max < s[i][j]) {
        s_max = s[i][j];
        t[i] = j + 1;
      }
    }
  }
  rep(i, d) { cout << t[i] << endl; }
  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  rep(i, 26) cin >> c[i];
  vector<vector<int>> s;
  rep(i, d) {
    rep(j, 26) { cin >> s[i][j]; }
  }
  vector<int> t(d);
  rep(i, d) {
    int s_max = 0;
    rep(j, 26) {
      if (s_max < s[i][j]) {
        s_max = s[i][j];
        t[i] = j;
      }
    }
  }
  rep(i, 26) { cout << t[i] << endl; }
  return 0;
}
Problem p02618 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using ll = long long;

vector<int> c;
vector<vector<int>> s;
int D;
vector<int> v;
vector<set<int>> U;

ll calc() {
  ll ans = 0;
  vector<int> last(26, 0);
  for (int i = 0; i < D; i++) {
    last[v[i] - 1] = i + 1;
    ans += s[i][v[i] - 1];
    // cout<<s[i][v[i] - 1]<<endl;
    for (int j = 0; j < 26; j++) {
      ans -= (ll)(i + 1 - last[j]) * c[j];
    }
  }
  return ans;
}

int retrnd(int n) { // 乱数生成
  std::random_device rnd;
  std::mt19937 mt(rnd());
  std::uniform_int_distribution<> rand100(0, n);
  return rand100(mt);
}

int main() {
  cin >> D;
  for (int i = 0; i < 26; i++) {
    int a;
    cin >> a;
    c.push_back(a);
  }
  for (int i = 0; i < D; i++) {
    vector<int> a;
    for (int j = 0; j < 26; j++) {
      int b;
      cin >> b;
      a.push_back(b);
    }
    s.push_back(a);
  }
  U = vector<set<int>>(26);
  for (int i = 0; i < D; i++) {
    v.push_back(retrnd(25) + 1);
  }
  int now = calc();
  int try_cnt = 1000;
  for (int cnt = 0; cnt < try_cnt; cnt++) {
    int rnd = retrnd(D - 1);
    for (int i = 1; i < 27; i++) {
      int prev = v[rnd];
      v[rnd] = i;
      int w = calc();
      if (now > w) {
        v[rnd] = prev;
      } else {
        now = w;
      }
    }
  }
  for (int i = 0; i < D; i++) {
    cout << v[i] << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using ll = long long;

vector<int> c;
vector<vector<int>> s;
int D;
vector<int> v;
vector<set<int>> U;

ll calc() {
  ll ans = 0;
  vector<int> last(26, 0);
  for (int i = 0; i < D; i++) {
    last[v[i] - 1] = i + 1;
    ans += s[i][v[i] - 1];
    // cout<<s[i][v[i] - 1]<<endl;
    for (int j = 0; j < 26; j++) {
      ans -= (ll)(i + 1 - last[j]) * c[j];
    }
  }
  return ans;
}

int retrnd(int n) { // 乱数生成
  std::random_device rnd;
  std::mt19937 mt(rnd());
  std::uniform_int_distribution<> rand100(0, n);
  return rand100(mt);
}

int main() {
  cin >> D;
  for (int i = 0; i < 26; i++) {
    int a;
    cin >> a;
    c.push_back(a);
  }
  for (int i = 0; i < D; i++) {
    vector<int> a;
    for (int j = 0; j < 26; j++) {
      int b;
      cin >> b;
      a.push_back(b);
    }
    s.push_back(a);
  }
  U = vector<set<int>>(26);
  for (int i = 0; i < D; i++) {
    v.push_back(retrnd(25) + 1);
  }
  int now = calc();
  int try_cnt = 10000;
  for (int cnt = 0; cnt < try_cnt; cnt++) {
    int rnd = retrnd(D - 1);
    for (int i = 1; i < 27; i++) {
      int prev = v[rnd];
      v[rnd] = i;
      int w = calc();
      if (now > w) {
        v[rnd] = prev;
      } else {
        now = w;
      }
    }
  }
  for (int i = 0; i < D; i++) {
    cout << v[i] << endl;
  }
}
Problem p02618 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c)                                                            \\
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\\n"

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long lint;

using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d;
  // lint max=0;
  cin >> d;
  vector<int> c(26), ans(d);
  vector<vector<int>> s(d, vector<int>(26));
  vector<int> last(26, 0);
  rep(i, 26) cin >> c[i];
  rep(i, d) rep(j, 26) cin >> s[i][j];
  rep(i, d) {
    auto a = s[i];
    map<int, int, greater<int>> m;
    rep(j, 26) { m.emplace(a[j] + (d - last[j]) * c[j], j); }
    ans[i] = (*m.begin()).second;
    last[ans[i]] = i + 1;
  }
  rep(i, d) cout << ans[i] + 1 << endl;
}

Error: -6
double free or corruption (out)


Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c)                                                            \\
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\\n"

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long lint;

using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d;
  lint max = 0;
  cin >> d;
  vector<int> c(26), ans(d);
  vector<vector<int>> s(d, vector<int>(26));
  vector<int> last(26, 0);
  rep(i, 26) cin >> c[i];
  rep(i, d) rep(j, 26) cin >> s[i][j];
  rep(i, d) {
    auto a = s[i];
    map<int, int, greater<int>> m;
    rep(j, 26) { m.emplace(a[j] + (d - last[j]) * c[j], j); }
    ans[i] = (*m.begin()).second;
    last[ans[i] - 1] = i + 1;
  }
  rep(i, d) cout << ans[i] + 1 << endl;
}
Problem p02618 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge {
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int D;
  cin >> D;
  vector<int> c(26);
  for (auto &it : c)
    cin >> it;
  vector<vector<ll>> s(D, vector<ll>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }

  vector<ll> last(26, 0);
  vector<ll> t(D);

  ll score = 0;
  for (int i = 0; i < D; i++) {
    ll now = 0;
    ll best_contest = 0;
    for (int co = 0; co < 26; co++) {
      ll tmp = 0;
      vector<ll> this_last = last;
      this_last[co] = i + 1;
      tmp += s[i][co];
      for (int j = 0; j < 26; j++) {
        tmp -= c[j] * ((i + 1) - this_last[j]);
      }
      if (tmp > now) {
        now = max(now, tmp);
        best_contest = co;
      }
    }
    last[best_contest] = i + 1;
    score += now;
    cout << best_contest + 1 << endl;
  }
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge {
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int D;
  cin >> D;
  vector<int> c(26);
  for (auto &it : c)
    cin >> it;
  vector<vector<ll>> s(D, vector<ll>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }

  vector<ll> last(26, 0);

  vector<ll> t(D);

  ll score = 0;
  for (int i = 0; i < D; i++) {
    ll now = 0;
    ll best_contest = -1;
    for (int co = 0; co < 26; co++) {
      ll tmp = 0;
      vector<ll> this_last = last;
      this_last[co] = i + 1;
      tmp += s[i][co];
      for (int j = 0; j < 26; j++) {
        tmp -= c[j] * ((i + 1) - this_last[j]);
      }
      if (tmp > now) {
        now = max(now, tmp);
        best_contest = co;
      }
    }
    last[best_contest] = i + 1;
    score += now;
    cout << best_contest + 1 << endl;
  }
  return 0;
}
Problem p02618 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//

signed main() {
  int d;
  clock_t st = clock();
  cin >> d;
  clock_t ed = clock();

  int c[26];
  for (int i = 0; i < 26; i++)
    cin >> c[i];
  int t[d], s[d][26], x[26] = {};
  vector<int> v[26];
  for (int i = 0; i < 26; i++)
    v[i].push_back(-1);

  for (int i = 0; i < d; i++)
    for (int j = 0; j < 26; j++)
      cin >> s[i][j];
  // cerr<<'i';
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++)
      x[j] += c[j];
    int k = 0;
    for (int j = 1; j < 26; j++)
      if (x[k] + s[i][k] < x[j] + s[i][j])
        k = j;
    t[i] = k;
    x[k] = 0;
    v[k].push_back(i);
  }
  for (int i = 0; i < 26; i++)
    v[i].push_back(d);
  // for(int i=0;i<d;i++)cout<<t[i]+1<<endl;
  //  cerr<<double(clock()-st)/CLOCKS_PER_SEC<<endl;
  while (double(clock() - st) / CLOCKS_PER_SEC < 1.90) {
    int p = rand() % d;
    auto q = find(v[t[p]].begin(), v[t[p]].end(), p);
    q++;
    int m = (p + (*q)) / 2;
    // int m=p+rand()%((*q)-p);
    // cerr<<m<<' '<<p<<endl;
    if (m == p)
      continue;
    auto r1 = find(v[t[m]].begin(), v[t[m]].end(), m);
    auto r0 = r1 - 1, r2 = r1 + 1;
    if ((m - p) * ((*q) - m) * c[t[p]] + s[m][t[p]] >
        (m - (*r0)) * ((*r2) - m) * c[t[m]] + s[m][t[m]]) {

      v[t[p]].insert(q, m);
      v[t[m]].erase(r1);
      t[m] = t[p];
    }
  }
  for (int i = 0; i < d; i++)
    cout << t[i] + 1 << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//

signed main() {
  int d;
  clock_t st = clock();
  cin >> d;
  clock_t ed = clock();

  int c[26];
  for (int i = 0; i < 26; i++)
    cin >> c[i];
  int t[d], s[d][26], x[26] = {};
  vector<int> v[26];
  for (int i = 0; i < 26; i++)
    v[i].push_back(-1);

  for (int i = 0; i < d; i++)
    for (int j = 0; j < 26; j++)
      cin >> s[i][j];
  // cerr<<'i';
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++)
      x[j] += c[j];
    int k = 0;
    for (int j = 1; j < 26; j++)
      if (x[k] + s[i][k] < x[j] + s[i][j])
        k = j;
    t[i] = k;
    x[k] = 0;
    v[k].push_back(i);
  }
  for (int i = 0; i < 26; i++)
    v[i].push_back(d);
  for (int i = 0; i < d; i++)
    cout << t[i] + 1 << endl;
  // cerr<<(clock()-st)/CLOCKS_PER_SEC<<endl;
  while ((clock() - st) / CLOCKS_PER_SEC < 1.95) {
    int p = rand() % d;
    auto q = find(v[t[p]].begin(), v[t[p]].end(), p);
    q++;
    int m = (p + (*q)) / 2;
    // int m=p+rand()%((*q)-p);
    // cerr<<m<<' '<<p<<endl;
    if (m == p)
      continue;
    auto r1 = find(v[t[m]].begin(), v[t[m]].end(), m);
    auto r0 = r1 - 1, r2 = r1 + 1;
    if ((m - p) * ((*q) - m) * c[t[p]] + s[m][t[p]] >
            (m - (*r0)) * ((*r2) - m) * c[t[m]] + s[m][t[m]] ||
        rand() % 1950 > (clock() - st) / CLOCKS_PER_SEC * 1000) {

      v[t[p]].insert(q, m);
      v[t[m]].erase(r1);
      t[m] = t[p];
    }
  }
  for (int i = 0; i < d; i++)
    cout << t[i] + 1 << endl;
}
Problem p02618 (C++) — buggy submission, verdict: Runtime Error

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

// ある一日でコンテストタイプtiを開催した場合の得点
int calc_point(int stf, vector<vector<int>> sds, vector<int> cs, int d,
               vector<int> lds, int ti) {
  int cnt = 0;
  stf += sds[d][ti];
  for (int j = 0; j < 26; j++)
    cnt += cs[j] * (d + 1 - lds[j]);

  stf -= cnt;
  return stf;
}

int main() {
  int D;
  cin >> D;
  vector<int> cs(26);
  vector<vector<int>> sds(D, vector<int>(26));
  for (int i = 0; i < 26; i++)
    cin >> cs[i];

  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> sds[i][j];
    }
  }
  // 貪欲法
  int stf = 0;
  vector<int> lds(26);
  for (int i = 0; i < D; i++) {
    int last_ti, last_score;
    last_ti = last_score = -INF;
    for (int j = 0; j < 26; j++) {
      if (i <= 37) {
        // cout << "j: "  << j << endl;
      }
      int score = calc_point(stf, sds, cs, i, lds, j);
      if (score > last_score) {
        last_score = score;
        last_ti = j;
      }
    }
    lds[last_ti] = i + 1;
    stf = last_score;

    cout << last_ti + 1 << endl;
    // cout << "i: " << i << endl;
  }
}

Error: 0

Fixed submission:

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

int D;
vector<int> cs(26);
vector<vector<int>> sds(D, vector<int>(26));

// ある一日でコンテストタイプtiを開催した場合の得点
int calc_point(int stf, int d, vector<int> lds, int ti) {
  int cnt = 0;
  stf += sds[d][ti];
  for (int j = 0; j < 26; j++) {
    cnt += cs[j] * (d + 1 - lds[j]);
  }
  stf -= cnt;
  return stf;
}

int main() {
  cin >> D;
  sds.resize(D, vector<int>(26));

  for (int i = 0; i < 26; i++)
    cin >> cs[i];

  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> sds[i][j];
    }
  }
  // 貪欲法
  int stf = 0;
  vector<int> lds(26);
  for (int i = 0; i < D; i++) {
    int last_ti, last_score;
    last_ti = last_score = -1;
    for (int j = 0; j < 26; j++) {
      int score = calc_point(stf, i, lds, j);
      if (score > last_score) {
        last_score = score;
        last_ti = j;
      }
    }
    lds[last_ti] = i + 1;

    cout << last_ti + 1 << endl;
  }
}
Problem p02618 (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 REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define RREP(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < b; i++)

int main() {
  int d;
  int temp = 0;
  vector<int> c(26);
  vector<int> ci(26);
  vector<int> rec(26, 0);
  vector<int> late(27, 0);
  cin >> d;
  REP(i, 26) cin >> c.at(i);

  REP1(days, d) {
    /*if(days>d-26){
            REP1(i,25)if(c.at(temp)<c.at(i) && rec.at(i)==0){
                    rec.at(i)=1;
                    temp=i;
                    }
            cout << temp+1 << endl;
            //late.at(temp+1)=days;
            temp=0;
            break;
    }*/

    REP(i, 26) cin >> ci.at(i);
    REP1(i, 25) if (ci.at(temp) < ci.at(i)) temp = i;
    cout << temp + 1 << endl;
    // late.at(temp+1)=days;
    temp = 0;
  }
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define RREP(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < b; i++)

int main() {
  int d;
  int temp = 0;
  vector<int> c(26);
  vector<int> ci(26);
  vector<int> rec(26, 0);
  vector<int> late(26, 0);
  cin >> d;
  REP(i, 26) cin >> c.at(i);

  REP(days, d) {
    if (days > d - 26) {
      REP1(i, 25) if (c.at(temp) < c.at(i) && rec.at(i) == 0) {
        rec.at(i) = 1;
        temp = i;
      }
      cout << temp + 1 << endl;
      late.at(temp + 1) = days;
      temp = 0;
      break;
    }

    REP(i, 26) cin >> ci.at(i);
    REP1(i, 25) if (ci.at(temp) < ci.at(i)) temp = i;
    cout << temp + 1 << endl;
    late.at(temp + 1) = days;
    temp = 0;
  }
}