Language: C++

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

int score(const int d, const vector<vector<int>>&s, const vector<int>&c, vector<int>&contests, vector<int>&last, vector<int>&satis, int beg) {
  //vector<int> contests(d);
  //vector<int> last(26, 0);
  for (int i = 0; i < 26; i++) last[i] = 0;
  int sat = (beg == 0) ? 0 : satis[beg-1];
  //int sat = 0;
  //makecontest(s, c, last, contests);

  for (int i = 0; i < d; i++) {
    //cout << d << " " << i << endl;
    last[contests[i]-1] = i+1;
    if (i < beg) continue;
    sat += s[i][contests[i]-1];
    for (int j = 0; j < 26; j++) {
      sat -= c[j] * (i+1 - last[j]);
    }
    //cout << sat << endl;
    satis[i] = sat;
  }
  return sat;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15);

  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> contests(d);
  vector<int> templast(26, 0);
  //for (int i = 0; i < d; i++) cin >> contests[i];
  for (int i = 0; i < d; i++) {
    int mx = -INF, ct;
    for (int j = 0; j < 26; j++) {
      //mx = max(mx, s[i][j]);
      //if (mx == s[i][j]) ct = j+1;
      int temp = s[i][j];
      for (int k = 0; k < 26; k++) {
        if (j != k) temp -= c[k] * (i+1 - templast[k]);
      }
      if (mx < temp) {
        ct = j+1;
        mx = temp;
      }
    }
    contests[i] = ct;
    templast[ct-1] = i+1;
  }
  
  vector<int> last(26, 0);
  vector<int> satis(d, 0), rec(d);
  int param1 = 2, param2 = 1;
  int sc = score(d, s, c, contests, last, satis, 0);
  for (int i = 0; i < d; i++) rec[i] = satis[i];
  //cout << sc << endl;
  for (int p = 0; p < 420000; p++) {
    srand(p);
    int op = rand() % param1;
    if (op < param1) {
      int day = rand() % d;
      int q = rand() % 26;
      //cout << day << " " << q << endl;
      int old = contests[day];
      contests[day] = q + 1;
      int ts = score(d, s, c, contests, last, satis, day);
      //cout << ts << endl;
      if (ts < sc) {
        contests[day] = old;
        for (int i = day; i < d; i++) satis[i] = rec[i];
        continue;
      }
      sc = ts;
      for (int i = day; i < d; i++) rec[i] = satis[i];
      //cout << sc << endl;
    }
    //cout << sc << endl;
    else {
      int day1 = rand() % d;
      int day2 = rand() % d;
      if (day1 == day2) continue;
      //cout << day << " " << q << endl;
      //int old = contests[day];
      //contests[day] = q + 1;
      swap(contests[day1], contests[day2]);
      int day = min(day1, day2);
      int ts = score(d, s, c, contests, last, satis, day);
      //cout << ts << endl;
      if (ts < sc) {
        //contests[day] = old;
        swap(contests[day1], contests[day2]);
        for (int i = day; i < d; i++) satis[i] = rec[i];
        continue;
      }
      sc = ts;
      for (int i = day; i < d; i++) rec[i] = satis[i];
      //cout << sc << endl;
    }
  }
  for (int i = 0; i < d; i++) cout << contests[i] << endl;
}


Compiler output:
a.cc:4:13: error: 'pair' does not name a type
    4 | using pii = pair<int, int>;
      |             ^~~~
a.cc:5:13: error: 'pair' does not name a type
    5 | using pll = pair<ll, ll>;
      |             ^~~~
a.cc:6:14: error: 'pair' does not name a type
    6 | using pull = pair<ull, ll>;
      |              ^~~~
a.cc:7:13: error: 'pair' does not name a type
    7 | using pis = pair<int, string>;
      |             ^~~~
a.cc:12:30: error: 'vector' does not name a type
   12 | int score(const int d, const vector<vector<int>>&s, const vector<int>&c, vector<int>&contests, vector<int>&last, vector<int>&satis, int beg) {
      |                              ^~~~~~
a.cc:12:36: error: expected ',' or '...' before '<' token
   12 | int score(const int d, const vector<vector<int>>&s, const vector<int>&c, vector<int>&contests, vector<int>&last, vector<int>&satis, int beg) {
      |                                    ^
a.cc: In function 'int score(int, int)':
a.cc:15:32: error: 'last' was not declared in this scope
   15 |   for (int i = 0; i < 26; i++) last[i] = 0;
      |                                ^~~~
a.cc:16:14: error: 'beg' was not declared in this scope
   16 |   int sat = (beg == 0) ? 0 : satis[beg-1];
      |              ^~~
a.cc:16:30: error: 'satis' was not declared in this scope; did you mean 'sat'?
   16 |   int sat = (beg == 0) ? 0 : satis[beg-1];
      |                              ^~~~~
      |                              sat
a.cc:22:5: error: 'last' was not declared in this scope
   22 |     last[contests[i]-1] = i+1;
      |     ^~~~
a.cc:22:10: error: 'contests' was not declared in this scope; did you mean 'const'?
   22 |     last[contests[i]-1] = i+1;
      |          ^~~~~~~~
      |          const
a.cc:24:12: error: 's' was not declared in this scope
   24 |     sat += s[i][contests[i]-1];
      |            ^
a.cc:26:14: error: 'c' was not declared in this scope
   26 |       sat -= c[j] * (i+1 - last[j]);
      |              ^
a.cc: In function 'int main()':
a.cc:35:3: error: 'cin' was not declared in this scope
   35 |   cin.tie(0);
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:36:3: error: 'ios' has not been declared
   36 |   ios::sync_with_stdio(false);
      |   ^~~
a.cc:41:3: error: 'vector' was not declared in this scope
   41 |   vector<int> c(26);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:41:10: error: expected primary-expression before 'int'
   41 |   vector<int> c(26);
      |          ^~~
a.cc:42:39: error: 'c' was not declared in this scope
   42 |   for (int i = 0; i < 26; i++) cin >> c[i];
      |                                       ^
a.cc:43:17: error: expected primary-expression before 'int'
   43 |   vector<vector<int>> s(d, vector<int>(26));
      |                 ^~~
a.cc:46:14: error: 's' was not declared in this scope
   46 |       cin >> s[i][j];
      |              ^
a.cc:50:10: error: expected primary-expression before 'int'
   50 |   vector<int> contests(d);
      |          ^~~
a.cc:51:10: error: expected primary-expression before 'int'
   51 |   vector<int> templast(26, 0);
      |          ^~~
a.cc:58:18: error: 's' was not declared in this scope
   58 |       int temp = s[i][j];
      |                  ^
a.cc:60:29: error: 'c' was not declared in this scope
   60 |         if (j != k) temp -= c[k] * (i+1 - templast[k]);
      |                             ^
a.cc:60:43: error: 'templast' was not declared in this scope
   60 |         if (j != k) temp -= c[k] * (i+1 - templast[k]);
      |                                           ^~~~~~~~
a.cc:67:5: error: 'contests' was not declared in this scope; did you mean 'const'?
   67 |     contests[i] = ct;
      |     ^~~~~~~~
      |     const
a.cc:68:5: error: 'templast' was not declared in this scope
   68 |     templast[ct-1] = i+1;
      |     ^~~~~~~~
a.cc:71:10: error: expected primary-expression before 'int'
   71 |   vector<int> last(26, 0);
      |          ^~~
a.cc:72:10: error: expected primary-expression before 'int'
   72 |   vector<int> satis(d, 0), rec(d);
      |          ^~~
a.cc:74:21: error: 's' was not declared in this scope; did you mean 'sc'?
   74 |   int sc = score(d, s, c, contests, last, satis, 0);
      |                     ^
      |                     sc
a.cc:74:24: error: 'c' was not declared in this scope; did you mean 'sc'?
   74 |   int sc = score(d, s, c, contests, last, satis, 0);
      |                        ^
      |                        sc
a.cc:74:27: error: 'contests' was not declared in this scope; did you mean 'const'?
   74 |   int sc = score(d, s, c, contests, last, satis, 0);
      |                           ^~~~~~~~
      |                           const
a.cc:74:37: error: 'last' was not declared in this scope
   74 |   int sc = score(d, s, c, contests, last, satis, 0);
      |                                     ^~~~
a.cc:74:43: error: 'satis' was not declared in this scope; did you mean 'static'?
   74 |   int sc = score(d, s, c, contests, last, satis, 0);
      |                                           ^~~~~
      |                                           static
a.cc:75:31: error: 'rec' was not declared in this scope
   75 |   for (int i = 0; i < d; i++) rec[i] = satis[i];
      |                               ^~~
a.cc:78:5: error: 'srand' was not declared in this scope
   78 |     srand(p);
      |     ^~~~~
a.cc:79:14: error: 'rand' was not declared in this scope
   79 |     int op = rand() % param1;
      |              ^~~~
a.cc:90:50: error: 'rec' was not declared in this scope
   90 |         for (int i = day; i < d; i++) satis[i] = rec[i];
      |                                                  ^~~
a.cc:94:37: error: 'rec' was not declared in this scope
   94 |       for (int i = day; i < d; i++) rec[i] = satis[i];
      |                                     ^~~
a.cc:105:7: error: 'swap' was not declared in this scope
  105 |       swap(contests[day1], contests[day2]);
      |       ^~~~
a.cc:106:17: error: 'min' was not declared in this scope; did you mean 'main'?
  106 |       int day = min(day1, day2);
      |                 ^~~
      |                 main
a.cc:112:50: error: 'rec' was not declared in this scope
  112 |         for (int i = day; i < d; i++) satis[i] = rec[i];
      |                                                  ^~~
a.cc:116:37: error: 'rec' was not declared in this scope
  116 |       for (int i = day; i < d; i++) rec[i] = satis[i];
      |                                     ^~~
a.cc:120:31: error: 'cout' was not declared in this scope
  120 |   for (int i = 0; i < d; i++) cout << contests[i] << endl;
      |                               ^~~~
a.cc:120:31: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:120:54: error: 'endl' was not declared in this scope
  120 |   for (int i = 0; i < d; i++) cout << contests[i] << endl;
      |                                                      ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;