結果
問題 | No.5007 Steiner Space Travel |
ユーザー |
![]() |
提出日時 | 2025-03-06 02:32:55 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,318 bytes |
コンパイル時間 | 8,056 ms |
コンパイル使用メモリ | 351,984 KB |
実行使用メモリ | 8,612 KB |
スコア | 0 |
最終ジャッジ日時 | 2025-03-06 02:34:04 |
合計ジャッジ時間 | 68,994 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 30 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace atcoder; using namespace __gnu_pbds; using mint = modint998244353; #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define print(var) std::cout<<#var<<"="<<(var)<<std::endl #define all(a) (a).begin(), (a).end() #define vi vector<int> #define vvi vector<vi> #define vvvi vector<vvi> #define ll long long #define vll vector<ll> #define vvll vector<vll> #define vvvll vector<vvll> #define vvvvll vector<vvvll> #define vmi vector<mint> #define vvmi vector<vmi> #define vvvmi vector<vvmi> #define vvvvmi vector<vvvmi> #define vvvvvmi vector<vvvvmi> #define vs vector<string> #define pii pair<int,int> #define vpii vector<pii> #define vvpii vector<vpii> #define bit(x,i)(((x)>>(i))&1) #define inf (1<<30) #define INF (1ll<<60) #define X first #define Y second template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); } template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); } template<class T, class F> T nibutan(T ok, T ng, const F &f){while(abs(ok-ng)>1){T mid = (ok+ng)/2;(f(mid)?ok:ng) = mid;}return ok;} template<class T> vector<T> digit(T x){vector<T> res; while(x>0){res.push_back(x%10); x/=10;} return res;} ostream& operator<<(ostream& os, const mint& x){ os << x.val(); return os; } template<class T> istream &operator>>(istream &is, vector<T> &vec){ for(auto &v:vec) is >> v; return is; } template<class T> void coutvector(vector<T> x){ for(int i=0;i<(int)x.size();i++){if(i>0) cout<<" ";cout<<x[i];}cout<<endl;} using Set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>; template<class S, class T> using Unordered_Map = gp_hash_table<S,T>; #ifdef LOCAL #include<dump.hpp> CPP_DUMP_DEFINE_EXPORT_OBJECT(mint,val()); #else #define cpp_dump #endif inline double get_time() { #ifdef ONLINE_JUDGE timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec * 1e3 + tv.tv_usec * 1e-3; #else using namespace std::chrono; return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count(); #endif } double start_time = get_time(); inline double elapsed(){ return get_time() - start_time; } static uint32_t xor128(void){ static uint32_t x=123456789,y=362436069,z=521288629,w=88675123; uint32_t t; t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) ); } inline int randrange(int a){return (uint64_t(xor128()) * a >> 32); } inline int randrange(int a, int b){ return randrange(b-a)+a; } inline double randDouble(double a,double b){return a+(b-a)*xor128()/(double)ULONG_MAX;} const int N = 100, M = 8; vector<int> a(N),b(N); void in(){ int tmp; cin>>tmp>>tmp; for(int i=0;i<N;i++){ cin>> a[i] >> b[i]; } } int dist(int x, int y){ return (a[x]-a[y])*(a[x]-a[y]) + (b[x]-b[y])*(b[x]-b[y]); } vi init_sol(){ vi ret(N); iota(all(ret),0); ret.push_back(0); return ret; } void solve(){ vi sol = init_sol(); int now_score = 0; for(int i=0;i<N;i++){ now_score += 25*dist(sol[i],sol[i+1]); } int best_score = now_score; cerr << "init score: " << now_score << endl; int iter = 0; while(elapsed() < 1900){ int l,r; do{ l = randrange(1,N); r = randrange(1,N); }while(l==r); if(l>r) swap(l,r); int diff = 0; diff -= 25*(dist(sol[l-1],sol[l]) + dist(sol[r],sol[r+1])); diff += 25*(dist(sol[l-1],sol[r]) + dist(sol[l],sol[r+1])); if(diff < 0){ reverse(sol.begin()+l,sol.begin()+r+1); now_score += diff; if(chmin(best_score,now_score)){ #ifndef ONLINE_JUDGE cerr << "update score: " << now_score << endl; #endif best_score = now_score; } } iter++; } #ifndef ONLINE_JUDGE cerr << "iter: " << iter << endl; #endif for(int i=0;i<M;i++) cout << 0 << " " << 0 << endl; cout << sol.size() << endl; for(int i=0;i<sol.size();i++){ cout << 1 << " " << sol[i]+1 << endl; } } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); in(); solve(); }