Language: C++

//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 26;
const int D = 365;

int d;

int c[N];
int s[D][N];

int last[N];
int evaluate(const vi& t){
    memset(last, 0, sizeof last);
    int ret = 0;
    FOR(i,t.size()){
        ret += s[i][t[i]];
        last[t[i]] = i+1;

        FOR(j,N){
            ret -= c[j] * (i+1 - last[j]);
        }
    }
    return ret;
}

vi gen_rand(){
    vi ret;
    FOR(i,d){
        ret.pb(irand(0, N-1));
    }
    return ret;
}

vi gen_greed(){
    vi ret;
    FOR(i,d){
        // bruteforce
        int best = -1, vbest = -OO;
        FOR(j,N){
            ret.pb(j);
            int v = evaluate(ret);
            if(v > vbest){
                vbest = v;
                best = j;
            }
            ret.pop_back();
        }

        ret.pb(best);
    }
    return ret;
}

vi mutate(vi vec){
    int num = irand(1, 1);
    FOR(i,num){
        int a = irand(0, d-1);
        int b = irand(0, N-1);
        vec[a] = b;
    }
    return vec;
}

vi cross(const vi& a, const vi& b){
    vi ret;
    int mid = irand(10, d-10);
    FOR(i,d){
        if(i <= mid){
            ret.pb(a[i]);
        }else{
            ret.pb(b[i]);
        }
    }
    return ret;
}

const int SS = 5;
const int ITER = 10000 / SS;
vector<pair<int, vi> >sample;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>d;
    FOR(i,N)cin>>c[i];
    FOR(i,d){
    	FOR(j,N){
    		cin>>s[i][j];
    	}
    }

    REP(i,1,1){
        vi t = gen_greed();
        sample.pb({-evaluate(t), t});
    }
    REP(i,2,SS){
        vi t = gen_rand();
        sample.pb({-evaluate(t), t});
    }
    sort(sample.begin(), sample.end());

    FOR(itr, ITER){
        // mutations
        FOR(i,SS){
            vi t = mutate(sample[i].S);
            sample.pb({-evaluate(t), t});
        }

        // cross
        FOR(i,3){
            REP(j,i+1,3){
                vi t = cross(sample[i].S, sample[j].S);
                sample.pb({-evaluate(t), t});
            }
        }

        // cull
        sort(sample.begin(), sample.end());
        while(sample.size() > SS){
            sample.pop_back();
        }
    }

    vi ans = sample[0].S;
    FOR(i,d){
        cout << ans[i]+1 << endl;
    }


    cerr << "final: " << evaluate(ans) << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:173:9: error: reference to 'sample' is ambiguous
  173 |         sample.pb({-evaluate(t), t});
      |         ^~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:177:9: error: reference to 'sample' is ambiguous
  177 |         sample.pb({-evaluate(t), t});
      |         ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:179:10: error: reference to 'sample' is ambiguous
  179 |     sort(sample.begin(), sample.end());
      |          ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:179:26: error: reference to 'sample' is ambiguous
  179 |     sort(sample.begin(), sample.end());
      |                          ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:184:27: error: reference to 'sample' is ambiguous
  184 |             vi t = mutate(sample[i].S);
      |                           ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:185:13: error: reference to 'sample' is ambiguous
  185 |             sample.pb({-evaluate(t), t});
      |             ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:191:30: error: reference to 'sample' is ambiguous
  191 |                 vi t = cross(sample[i].S, sample[j].S);
      |                              ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:191:43: error: reference to 'sample' is ambiguous
  191 |                 vi t = cross(sample[i].S, sample[j].S);
      |                                           ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:192:17: error: reference to 'sample' is ambiguous
  192 |                 sample.pb({-evaluate(t), t});
      |                 ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:197:14: error: reference to 'sample' is ambiguous
  197 |         sort(sample.begin(), sample.end());
      |              ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:197:30: error: reference to 'sample' is ambiguous
  197 |         sort(sample.begin(), sample.end());
      |                              ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:198:15: error: reference to 'sample' is ambiguous
  198 |         while(sample.size() > SS){
      |               ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:199:13: error: reference to 'sample' is ambiguous
  199 |             sample.pop_back();
      |             ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~
a.cc:203:14: error: reference to 'sample' is ambiguous
  203 |     vi ans = sample[0].S;
      |              ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:5826:5: note: candidates are: 'template<class _PopulationIterator, class _SampleIterator, class _Distance, class _UniformRandomBitGenerator> _SampleIterator std::sample(_PopulationIterator, _PopulationIterator, _SampleIterator, _Distance, _UniformRandomBitGenerator&&)'
 5826 |     sample(_PopulationIterator __first, _PopulationIterator __last,
      |     ^~~~~~
a.cc:152:23: note:                 'std::vector<std::pair<int, std::vector<int> > > sample'
  152 | vector<pair<int, vi> >sample;
      |                       ^~~~~~