Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

using namespace std::chrono;
inline ll get_time_millisec(void) {
	return static_cast<ll>(duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count());
}

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

inline int getRange(int l, int r) {
	return xor128() % (r + 1 - l) + l;
}


class Solver {

private:
	//要素
	ll D;
	ll C[26];
	ll hiku[26];
	ll S[365][26];
	ll date[365];
	pair<int, int> changenum;
	bool changeflag=true;
	int changeday;


public:
	void input() {
		changeflag = false;
		cin >> D;
		//D = 365;
		
		FOR(i, 0, 26) {
			cin >> C[i];
			if (C[i] > maxC.first) {
				maxC.first = C[i];
				maxC.second = i;
			}
		}
		
		/*
		FOR(i, 0, 26) {
			C[i] = getRange(0, 100);
			
		}
		*/

		FOR(i, 0, D) {
			FOR(j, 0, 26) {
				cin >> S[i][j];
				//S[i][j] = getRange(0, 20000);



			}
			date[i] = xor128() % 26;
		}
	}

	int calcScore() {
		ll score = 0;
		ll last[365];
		FOR(i, 0, 26)last[i] = -1;

		if (!changeflag) {
			FOR(j, 0, 26)hiku[j] = 0;
			FOR(i, 0, D) {
				score += S[i][date[i]];
				last[date[i]] = i;

				FOR(j, 0, 26) {
					hiku[j] += C[j] * (i - last[j]);
				}
			}
			changeflag = false;
		}
		else {
			hiku[changenum.first] = 0;
			hiku[changenum.second] = 0;
			FOR(i, 0, D) {
				score += S[i][date[i]];
				last[date[i]] = 1;

				hiku[changenum.first] += C[changenum.first] * (i - last[changenum.first]);
				hiku[changenum.second] += C[changenum.second] * (i - last[changenum.second]);
			}
			//cout << hiku[changenum.first] << endl;
		}


		FOR(j, 0, 26)score -= hiku[j];
		//cout << score << endl;
		return score;
	}

	void init() {

		changeflag = true;

	}
	void rndchange() {
		ll t = xor128() % D;
		changenum.first = date[t];
		date[t] = xor128() % 26;
		changenum.second = date[t];  
	
	}
	void rndchange2() {
		ll t = xor128() % (D - 1);
		swap(date[t], date[t + 1]);
	}

	void output() {
		FOR(i, 0, D) {
			cout << date[i] + 1 << endl;
		}
		//changeflag = true;
		//cout << calcScore() << endl;
		//FOR(i, 0, 26)cout << hiku[i] << endl;
	}
};
ll cnt = 0;


Solver solve(void) {

	Solver currentSeq;

	currentSeq.input();
	currentSeq.init();


	Solver bestSeq = currentSeq;
	int bestScore = currentSeq.calcScore();
	int currentScore = bestScore;

	const ll saTimeStart = get_time_millisec();

	const ll saTimeEnd = saTimeStart + 1975;//milli
	double saTimeCurrent = saTimeStart;

	while (saTimeCurrent < saTimeEnd) {

		cnt++;

		Solver nextSeq = currentSeq;


		if (saTimeCurrent < saTimeEnd)nextSeq.rndchange();
		//else nextSeq.rndchange2();

		const int nextScore = nextSeq.calcScore();

		const ll T = saTimeEnd - saTimeStart;
		const ll t = saTimeCurrent - saTimeStart;
		const ll R = 10000;


		//const bool FORCE_NEXT = R * (T - t) > T*((xor128()) % (R));
		const bool FORCE_NEXT = false;
		/*
		double startTemp = 8000;
		double endTemp = 1;
		double temp = startTemp + (endTemp - startTemp)*t / T;
		double probability = exp((nextScore - currentScore) / temp);
		const bool FORCE_NEXT = probability > (double)(xor128() % R) / (double)R;
		*/
		//const bool FORCE_NEXT = (xor128() % R) > 999;


		if (nextScore > currentScore || FORCE_NEXT) {
			currentScore = nextScore;
			currentSeq = nextSeq;


		}


		if (currentScore > bestScore) {

			bestScore = currentScore;


			//cout << bestScore << endl;
			bestSeq = currentSeq;
		}
		saTimeCurrent = get_time_millisec();
	}

	return bestSeq;

}



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

	Solver ans = solve();
	ans.output();
	
	return 0;
}


Compiler output:
a.cc: In member function 'void Solver::input()':
a.cc:77:36: error: 'maxC' was not declared in this scope
   77 |                         if (C[i] > maxC.first) {
      |                                    ^~~~