#include #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep3(i, n, m) for (int i = m; i < (int)(n); i++) #define repr(i, n) for (int i = n-1; i >= 0; i--) #define all(v) v.begin(), v.end() #define SP << " " #define ll long long #define N_SIZE 100 #define M_SIZE 8 #define ALPHA 5 using namespace std; //定数周り int imax=2147483647; ll lmax=9223372036854775807; //焼きなましの定数 double TIME_LIMIT=985; double start_temp=100.0; double end_temp=1.0; //乱数の準備 // int seed=1; auto seed=(unsigned)time(NULL); mt19937_64 mt(seed); struct Pos{ int x; int y; Pos(){} Pos(int ix, int iy){ x=ix; y=iy; } bool operator<(const Pos &in) const{ return x!=in.x ? x1000){ cout<< x SP << p.x <=0); return rtn; // return (p.x-x)*(p.x-x)+(p.y-y)*(p.y-y); } double angle(Pos p){ return atan2(y-p.y, x-p.x); } void operator+=(const Pos pos){ x+=pos.x; y+=pos.y; } }; struct WayPoint{ int t; Pos pos; WayPoint(){} WayPoint(int it, Pos ipos){ t=it; pos=ipos; } int dist(WayPoint wp){ int dis=pos.euclid(wp.pos); assert(dis>=0); if(t==1) dis*=ALPHA; if(wp.t==1) dis*=ALPHA; assert(dis>=0); return dis; } }; struct Travel{ vector wp; vector tour; vector sta_route; vector>> cluster; int score(){ set st; ll s=0; rep(i, tour.size()-1){ s+=wp[tour[i]].dist(wp[tour[i+1]]); if(tour[i]> pai; Pos cent={500, 500}; rep3(i, N_SIZE+M_SIZE, N_SIZE) pai.push_back({wp[i].pos.angle(cent), i-N_SIZE}); sort(all(pai)); int idx; rep(i, M_SIZE){ if(pai[i].second==0){ idx=i; break; } } sta_route.clear(); rep(i, M_SIZE){ sta_route.push_back(pai[(i+idx)%M_SIZE].second); // cout<< sta_route[i] <=N_SIZE && tour[i+2]=0); assert(aft>=0); if(aft> n >> m; rep(i, N_SIZE){ cin>> planets[i].x >> planets[i].y; // a[i]=mt()%1001; // b[i]=mt()%1001; // cout<< a[i] SP << b[i] <(current - start).count() > TIME_LIMIT) break; // } // if(lp==400000) break; Travel travel=best; travel.move_station(); // 温度関数 double temp = start_temp + (end_temp - start_temp) * chrono::duration_cast(current - start).count() / TIME_LIMIT; // temp=10; // 遷移確率関数(最大化の場合) double prob = exp((travel.score()-best.score())/temp); // cout<< travel.score() < (mt()%imax)/(double)imax) { // 確率probで遷移する // if(lp%100==0){ // cout<< "lp:" << lp <