Problem:
Problem Statement

AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. AtCoder wants to schedule contests for D days so that user satisfaction is as high as possible. For every day, AtCoder will hold exactly one contest, and each contest will end on that day. The satisfaction is calculated as follows.

The satisfaction at the beginning of day 1 is 0. Satisfaction can be negative.

Holding contests increases satisfaction. The amount of increase will vary depending on a variety of factors. Specifically, we know in advance that holding a contest of type i on day d will increase the satisfaction by s_{d,i}.

If a particular type of contest is not held for a while, the satisfaction decreases. Each contest type i has an integer c_i, and at the end of each day d=1,2,...,D, the satisfaction decreases as follows. Let \mathrm{last}(d,i) be the last day before day d (including d) on which a contest of type i was held. If contests of type i have never been held yet, we define \mathrm{last}(d,i)=0. At the end of day d, the satisfaction decreases by \sum _{i=1}^{26}c_i \times (d-\mathrm{last}(d,i)).

Please schedule contests on behalf of AtCoder.
If the satisfaction at the end of day D is S, you will get a score of \max(10^6 + S, 0).
There are 50 test cases, and the score of a submission is the total scores for each test case.
You can make submissions multiple times, and the highest score among your submissions will be your score.

Constraints

D = 365

Each c_i is an integer satisfying 0\leq c_i \leq 100.

Each s_{d,i} is an integer satisfying 0\leq s_{d,i} \leq 20000.

Input

Input is given from Standard Input in the following format:

D
c_1 c_2 \cdots c_{26}
s_{1,1} s_{1,2} \cdots s_{1,26}
\vdots
s_{D,1} s_{D,2} \cdots s_{D,26}

Output

Let t_d (1\leq t_d \leq 26) be the type of the contest that will be held at day d.
Print D integers t_d to Standard Output in the following format:

t_1
t_2
\vdots
t_D

Any output that does not follow the above format may result in 0 pointsWA for that test case.

Input Generation

Each integer c_i and s_{d,i} is generated independently and uniformly at random from the integers in the range described in the problem statement.

Sample Input 1

5
86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82
19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424
6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570
6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256
8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452
19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192

Sample Output 1

1
17
13
14
13

Note that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case. The final satisfaction with this output is 79325, so the score is 1079325.

Input generator, score calculator, and visualizer

Beginner's Guide

If you don't know what to do, proceed to problem B or C.

Solution in Rust (1.42.0) (judge verdict: Accepted)

#![allow(non_snake_case, unused)]
use rand::prelude::*;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

#[macro_export]
#[allow(unused)]
macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

pub fn get_time() -> f64 {
	static mut STIME: f64 = -1.0;
	let t = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap();
	let ms = t.as_secs() as f64 + t.subsec_nanos() as f64 * 1e-9;
	unsafe {
		if STIME < 0.0 {
			STIME = ms;
		}
		ms - STIME
	}
}

#[derive(Clone, Debug)]
pub struct Input {
	pub D: usize,
	pub s: Vec<Vec<i64>>,
	pub c: Vec<i64>
}

fn read_input() -> Input {
	let D = read!(usize);
	let c = read!([i64]);
	let s = read!([i64]; D);
	Input { D, s, c }
}

pub fn compute_score(input: &Input, out: &Vec<usize>) -> i64 {
	let mut score = 0;
	let mut last = vec![0; 26];
	for d in 0..out.len() {
		last[out[d]] = d + 1;
		for i in 0..26 {
			score -= (d + 1 - last[i]) as i64 * input.c[i];
		}
		score += input.s[d][out[d]];
	}
	score
}

fn cost(a: usize, b: usize) -> i64 {
	let d = b - a;
	(d * (d - 1) / 2) as i64
}

struct State {
	out: Vec<usize>,
	score: i64,
	prev: Vec<Vec<usize>>,
	next: Vec<Vec<usize>>,
}

impl State {
	fn new(input: &Input, out: Vec<usize>) -> State {
		let mut prev = mat![!0; 26; input.D + 1];
		let mut next = mat![input.D; 26; input.D + 1];
		for d in 0..input.D {
			for i in 0..26 {
				prev[i][d + 1] = prev[i][d];
			}
			prev[out[d]][d + 1] = d;
		}
		for d in (0..input.D).rev() {
			for i in 0..26 {
				next[i][d] = next[i][d + 1];
			}
			next[out[d]][d] = d;
		}
		let score = compute_score(&input, &out);
		State { out, score, prev, next }
	}
	fn try_shift(&self, input: &Input, d: usize, d2: usize) -> i64 {
		let i = self.out[d];
		let prev = self.prev[i][d];
		let next = self.next[i][d + 1];
		let before = input.s[d][i] - input.c[i] * (cost(prev, d) + cost(d, next));
		let after = if d2 == !0 {
			-input.c[i] * cost(prev, next)
		} else {
			input.s[d2][i] - input.c[i] * (cost(prev, d2) + cost(d2, next))
		};
		after - before
	}
	fn try_insert(&self, input: &Input, d: usize, i: usize) -> i64 {
		let prev = self.prev[i][d];
		let next = self.next[i][d + 1];
		let before = -input.c[i] * cost(prev, next);
		let after = input.s[d][i] - input.c[i] * (cost(prev, d) + cost(d, next));
		after - before
	}
	fn update(&mut self, i: usize, prev: usize, d2: usize, next: usize) {
		for d in prev+1..=d2 {
			self.prev[i][d] = prev;
			self.next[i][d] = d2;
		}
		for d in d2+1..=next {
			self.prev[i][d] = d2;
			self.next[i][d] = next;
		}
	}
	fn change(&mut self, d: usize, i: usize) {
		let j = self.out[d];
		let (prev1, next1) = (self.prev[i][d], self.next[i][d + 1]);
		let (prev2, next2) = (self.prev[j][d], self.next[j][d + 1]);
		self.out[d] = i;
		self.update(i, prev1, d, next1);
		for d in prev2+1..=next2 {
			self.prev[j][d] = prev2;
			self.next[j][d] = next2;
		}
	}
}

fn dfs(input: &Input, state: &mut State, d: usize, diff: i64, diff0: i64, used: &mut Vec<bool>, s: usize, depth: usize) -> bool {
	if d != s {
		if s == !0 {
			let diff = diff + diff0 + state.try_shift(input, d, !0);
			if diff > 0 {
				state.score += diff;
				return true;
			}
		} else {
			let i = state.out[d];
			if state.prev[i][d] + 1 <= s && s < state.next[i][d + 1] {
				let diff = diff + state.try_shift(input, d, s);
				if diff > 0 {
					state.score += diff;
					state.change(s, i);
					return true;
				}
			}
		}
	}
	let i = state.out[d];
	let prev = state.prev[i][d];
	let next = state.next[i][d + 1];
	if depth < 2 {
		for d2 in prev+1..next {
			if used[state.out[d2]] {
				continue;
			}
			let diff = diff + state.try_shift(input, d, d2);
			if diff > 0 {
				let j = state.out[d2];
				used[j] = true;
				let ok = dfs(input, state, d2, diff, diff0, used, s, depth + 1);
				used[j] = false;
				if ok {
					state.change(d2, i);
					return true;
				}
			}
		}
	} else if s != !0 {
		let mut max_diff = 0;
		let mut max_d2 = !0;
		for d2 in prev+1..next {
			if used[state.out[d2]] {
				continue;
			}
			if max_diff.setmax(diff + state.try_shift(input, d, d2)) {
				max_d2 = d2;
			}
		}
		if max_diff > 0 {
			used[state.out[max_d2]] = true;
			let ok = dfs(input, state, max_d2, max_diff, diff0, used, s, depth + 1);
			used[state.out[max_d2]] = false;
			if ok {
				state.change(max_d2, i);
				return true;
			}
		}
	}
	false
}

fn solve(input: &Input) -> Vec<usize> {
	const T0: f64 = 2e3;
	const T1: f64 = 2e2;
	const TL: f64 = 1.95;
	let mut rng = rand_pcg::Pcg64Mcg::new(890482);
	let mut state = State::new(input, (0..input.D).map(|_| rng.gen_range(0, 26)).collect());
	let mut used = vec![false; 26];
	let mut cnt = 0;
	let mut best_score = state.score;
	let mut best = state.out.clone();
	loop {
		let t = get_time() / TL;
		if t >= 1.0 {
			break;
		}
		let T = T0.powf(1.0 - t) * T1.powf(t);
		let add = (-T * rng.gen::<f64>().ln()) as i64;
		cnt += 1;
		if rng.gen_bool(0.5) {
			let d = rng.gen_range(0, input.D);
			let i = rng.gen_range(0, 26);
			if state.out[d] == i {
				continue;
			}
			let j = state.out[d];
			let diff = state.try_insert(input, d, i);
			used[i] = true;
			used[j] = true;
			if dfs(input, &mut state, d, add + diff / 4, diff - diff / 4, &mut used, !0, 0) {
				state.change(d, i);
				state.score -= add;
			}
			used[i] = false;
			used[j] = false;
		} else {
			let s = rng.gen_range(0, input.D);
			let i = state.out[s];
			used[i] = true;
			if dfs(input, &mut state, s, add, 0, &mut used, s, 0) {
				state.score -= add;
			}
			used[i] = false;
		}
		if best_score.setmax(state.score) {
			best = state.out.clone();
			eprintln!("Time: {:.3}, Score: {}", get_time(), best_score);
		}
	}
	eprintln!("Iter = {}", cnt);
	best
}

fn run() {
	get_time();
	let input = read_input();
	let out = solve(&input);
	eprintln!("Time = {:.3}", get_time());
	eprintln!("Score = {}", compute_score(&input, &out));
	for i in 0..input.D {
		println!("{}", out[i] + 1);
	}
}