#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 using namespace std; //定数周り int imax=2147483647; ll lmax=9223372036854775807; //焼きなましの定数 double TIME_LIMIT=960; double start_temp=200000.0; double end_temp=10.0; //入力など int n, m; int a[100], b[100]; // 変数 int alp=5, sz=0; int c[8], d[8]; vector r(99); vector> s(100); ll b_sco, n_sco; //乱数の準備 //int seed=1; auto seed=(unsigned)time(NULL); mt19937_64 mt(seed); void inpt(){ cin>> n >> m; rep(i, 100){ cin>> a[i] >> b[i]; // a[i]=mt()%1001; // b[i]=mt()%1001; } } void init(){ rep(i, r.size()){ r[i]=i+2; } shuffle(all(r), mt); r.push_back(1); rep(i, 8){ c[i]=mt()%1001; d[i]=mt()%1001; } } ll score(){ ll sco=0; int px=a[0], py=b[0]; int nx, ny; rep(i, 100){ int tmp=alp*alp; rep(j, s[i].size()){ nx=c[s[i][j]-1]; ny=d[s[i][j]-1]; tmp=1; if(j==0 || j==s[i].size()-1) tmp=alp; sco+=tmp*((px-nx)*(px-nx)+(py-ny)*(py-ny)); px=nx; py=ny; } nx=a[r[i]-1]; ny=b[r[i]-1]; sco+=tmp*((px-nx)*(px-nx)+(py-ny)*(py-ny)); px=nx; py=ny; } return sco; } void print_ans(){ rep(i, 8) cout<< c[i] SP << d[i] <(current - start).count() > TIME_LIMIT) break; //if(lp==20000) break; int type=mt()%4+1; int idx1, idx2, dx, dy; vector pre_s; //cout<< "type:" << type <0) ins=mt()%s[idx2].size(); s[idx2].insert(s[idx2].begin()+ins, idx1); sz++; } }else{ // ステーション削除 idx2=mt()%99; pre_s=s[idx2]; if(s[idx2].size()>0){ idx1=mt()%s[idx2].size(); s[idx2].erase(s[idx2].begin()+idx1); sz--; } } n_sco=score(); //cout<< n_sco <(current - start).count() / TIME_LIMIT; // 遷移確率関数(最大化の場合) double prob = exp((b_sco-n_sco)/temp); if (prob > (mt()%imax)/(double)imax) { // 確率probで遷移する //if (nsco