Language: C++

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL,LL> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQGI; //大きい順
typedef priority_queue<int, VI, greater<int>> PQLI;
typedef priority_queue<PII> PQGP;
typedef priority_queue<PII, VPII, greater<PII>> PQLP;
//priority_queue<T,vector<T>,decltype(f)> pq{f};

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EB emplace_back
#define EF emplace_front
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).rbegin(), (c).rend())
#define LB lower_bound
#define UB upper_bound
#define NEXP next_permutation
#define FI first
#define SE second
#define Vmin(a) *min_element((a).begin(),(a).end())
#define Vmax(a) *max_element((a).begin(),(a).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORR(i,a,b) for(int i = (b-1);i>=(a);i--)
#define REPR(i,n) FORR(i,0,n)
#define CFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define CREP(i,n)  CFOR(i,0,n)
#define CFORR(i,a,b) for(int i = (b);i>=(a);i--)
#define CREPR(i,n) CFORR(i,0,n)
#define BFOR(bit,a,b) for(int bit = (a); bit < (1<<(b)); ++bit)
#define BREP(bit,n) BFOR(bit,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = INT_MAX/2;
const LL LINF = LLONG_MAX/3;
const int RINF = INT_MIN/2;
const LL RLINF = LLONG_MIN/3;
const LL MOD = 1e9+7;
const LL MODD = 998244353;
const int MAX = 510000;

inline bool Eq(double a, double b) { return fabs(b - a) < EPS; }

//other
//-------------------------------------------
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; }

#define ISIN(x,l,r) ((l) <= (x) && (x) < (r))
#define CEIL(x,y) (((x)+(y)-1)/(y))

template<typename T>
T Vsum(vector<T> &v){ T res(0); for(auto&&x:v) res += x; return res; }

#define COUT(x) cout << (x) << endl
#define COUT2(x,y) cout << (x) << " " << (y) << endl
#define COUT3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define BC(x) __builtin_popcountll(x)


LL Gcd(LL a, LL b) {return __gcd(a,b);}
LL Lcm(LL a, LL b) {return a/Gcd(a,b)*b;}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < SZ(v); i++) {
    os << v[i] << (i + 1 != SZ(v) ? " " : "");
  }
  return os;
}

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}


using TP = chrono::system_clock::time_point;
constexpr double TIME_LIMIT = 1960;
inline double passed_time(TP start){
  TP end = chrono::system_clock::now();
  return chrono::duration_cast<chrono::milliseconds>(end - start).count();
}

struct Xorshift{
  uint32_t x = 123456789;
  uint32_t y = 362436069;
  uint32_t z = 521288629;
  uint32_t w = 88675123;

  Xorshift(){};

  Xorshift(uint32_t x, uint32_t y, uint32_t z, uint32_t w): x(x), y(y), z(z), w(w){
    assert(x != 0 || y != 0 || z != 0 || w != 0);
  }

  uint32_t rand(){
    uint32_t t;
    t = x ^ (x << 11);
    x = y;
    y = z;
    z = w;
    w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    return w;
  }

  int randInt(int min = 0, int max = 5000){
      return int(rand() % (max - min + 1) + min);
  }

  double urand(){
      rand();
      return ((x + 0.5) / 4294967296.0 + w) / 4294967296.0;
  }

  double normrand(){
      return sqrt(-2 * log(urand())) * cos(2 * PI * urand());
  }
};

bool sigmoid_super(TP start_time,double randa,double begina, double enda){
    double div = TIME_LIMIT / (begina - enda);
    double x = passed_time(start_time);
    x = begina - (x / div);
    return (1.0 / (1 + exp(-x))) >= randa;
}

bool func_temp(double new_score, double pre_score, double randa, double start_temp, double end_temp,TP start){
    double temp = start_temp + (end_temp - start_temp) * passed_time(start) / TIME_LIMIT;
    double prob = exp((new_score - pre_score) / temp);
    return prob > randa;
}



VI c;
VVI s;

struct Solve{
  int D,N;
  VI T;
  VVI shedule;
  VI score, penalty;

  Solve(int D,int N,VI T):D(D),N(N),T(T) {
    shedule.assign(N,VI(1,0));
    score.assign(N,0);
    penalty.assign(N,0);
    REP(i,D){
      shedule[T[i]].PB(i+1);
    }
    REP(i,N) shedule[i].PB(D+1);

    REP(i,D){
      score[T[i]] += s[i][T[i]];
    }
    REP(i,N){
      int m = SZ(shedule[i]);
      REP(j,m-1){
        int d = shedule[i][j+1]-shedule[i][j];
        penalty[i] -= c[i]*d*(d-1)/2;
      }
    }
  }

  int getScore(){
    int res=0;
    for(auto e : score) res += e;
    for(auto e : penalty) res += e;
    return res;
  }

  void change(int k, int nt){
    int ot = T.at(k);
    T.at(k) = nt;

    score[ot] -= s[k][ot];
    score[nt] += s[k][nt];

    int m = SZ(shedule[ot]);
    int d;
    REP(i,m){
      if(shedule[ot][i] == k+1){
        d = shedule[ot][i]-shedule[ot][i-1];
        penalty[ot] += c.at(ot)*d*(d-1)/2;
        d = shedule[ot][i+1]-shedule[ot][i];
        penalty[ot] += c[ot]*d*(d-1)/2;
        d = shedule[ot][i+1]-shedule[ot][i-1];
        penalty[ot] -= c[ot]*d*(d-1)/2;

        shedule[ot].erase(shedule[ot].begin()+i);
        break;
      }
    }
    m = SZ(shedule[nt]);
    REP(i,m){
      if(shedule[nt][i] > k+1){

        d = shedule[nt][i]-shedule[nt][i-1];
        penalty[nt] += c[nt]*d*(d-1)/2;
        d = shedule[nt][i]-(k+1);
        penalt[nt] -= c[nt]*d*(d-1)/2;
        d = (k+1)-shedule[nt][i-1];
        penalty[nt] -= c[nt]*d*(d-1)/2;

        shedule[nt].insert(shedule[nt].begin()+i,k+1);
        break;
      }
    }
  }

  void tswap(int k, int l){
    int kt = T[k];
    int lt = T[l];
    change(k,lt);
    change(l,kt);
  }

};


const double T0 = 2e3;
const double T1 = 6e2;
const double Tl = 1.9;



int solve(){
  TP start;
  Xorshift xs;
  start = chrono::system_clock::now();
  //LL cnt = 0;
  //LL loop = 0;

  int D; cin >> D;
  int N = 26;
  c.assign(N,0); cin >> c;
  s.assign(D,VI(N,0)); cin >> s;
  
  VI T(D); //cin >> T;
  //REP(i,D) T.at(i)--;

  REP(i,D) T[i] = xs.randInt(0,N-1);

  Solve solve(D,N,T);

  while (passed_time(start) < TIME_LIMIT)
  {
      //cnt += sigmoid_super(start, xs.urand(), 3, -6);
      //loop++;


      int t = xs.randInt(0,1);

    int sco = solve.getScore();

    if(t){
      int k = xs.randInt(0,D-1);
      int nt = xs.randInt(0,N-1);
      int ot = T[k];
      solve.change(k,nt);
      int nsc = solve.getScore();
      if(sco>nsc){

        if(func_temp(nsc,sco,xs.urand(),T0,Tl,start)){
          T[k] = nt;
        }else{
          solve.change(k,ot);
        }
      }else{
        T[k] = nt;
      }
    }else{
      int l = xs.randInt(0,D-1);
      int r = xs.randInt(0,D-1);
      solve.tswap(l,r);
      int nsc = solve.getScore();
      if(sco>nsc){
        if(func_temp(nsc,sco,xs.urand(),T0,Tl,start)){
          swap(T[l],T[r]);
        }
        else{
          solve.tswap(l,r);
        }
      }else{
        swap(T[l],T[r]);
      }
    }

  }

  REP(i,D) T[i]++;

  COUT(T);

  //printf("cnt : %lld, loop : %lld, prob : %lf\n", cnt, loop, (cnt + 0.0)/loop);
  //return (cnt + 0.0) / loop;
  return solve.getScore();
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  

  LL cnt = 0;
    double sum = 0;
    REP(i, 1)
    {
        double ans = solve();
        //sum += ans;
    }
    //cout << sum / 10.0 << endl;

  return 0;
}


Compiler output:
a.cc: In member function 'void Solve::change(int, int)':
a.cc:273:9: error: 'penalt' was not declared in this scope; did you mean 'penalty'?
  273 |         penalt[nt] -= c[nt]*d*(d-1)/2;
      |         ^~~~~~
      |         penalty