結果
問題 |
No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance
|
ユーザー |
![]() |
提出日時 | 2022-10-19 02:50:40 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,960 ms / 2,000 ms |
コード長 | 2,494 bytes |
コンパイル時間 | 1,993 ms |
実行使用メモリ | 6,956 KB |
スコア | 1,397,128,335,558,394 |
最終ジャッジ日時 | 2022-10-19 02:52:36 |
合計ジャッジ時間 | 110,362 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for (long long i=0;i<(long long)(n);i++) #define all(v) v.begin(),v.end() using ll=long long; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; const ll INF=(1ll<<60); template<class T> void chmin(T &a,T b){ if(a>b){ a=b; } } template<class T> void chmax(T &a,T b){ if(a<b){ a=b; } } ll n,k; ll score(vector<ll> &t,vector<ll> &u,vector<ll> &ans){ double p=0; rep(i,k){ double now=0; vector<ll> x(n); rep(ii,n){ ll a=(t[i]-(ans[ii]+1))/(ans[ii]*2); ll b=(t[i]-(ans[ii]+1))%(ans[ii]*2); if(a%2==0){ x[ii]=ans[ii]-1-b; }else{ x[ii]=-ans[ii]+1+b; } } rep(ii,n-1){ for(ll jj=ii+1;jj<n;jj++){ now+=(double)abs(x[ii]-x[jj])/(double)(ans[ii]+ans[jj]); } } p+=2e7/((double)n*(n-1))*now; } double q=0; rep(i,k){ double now=0; vector<ll> x(n); rep(ii,n){ ll a=(t[i]-(ans[ii]+1))/(ans[ii]*2); ll b=(t[i]-(ans[ii]+1))%(ans[ii]*2); if(a%2==0){ x[ii]=ans[ii]-1-b; }else{ x[ii]=-ans[ii]+1+b; } } rep(ii,n-1){ for(ll jj=ii+1;jj<n;jj++){ chmax(now,(double)abs(x[ii]-x[jj])); } } q+=1e7/sqrt(now/20+1); } ll ret=(ll)(p/k)*(ll)(q/k); return ret; } int main(){ srand((unsigned int)time(NULL)); double start=clock(); cin >> n >> k; vector<ll> t(k),u(k); rep(i,k) cin >> t[i]; rep(i,k) cin >> u[i]; ll xxx=7; vector<ll> ans(n,xxx); ll max_score=score(t,u,ans); mt19937 mt(rand()); double time_limit=1.91; while(true){ double now=clock(); if(time_limit<(now-start)/CLOCKS_PER_SEC) break; ll x=mt()%n; ll h=ans[x]; ans[x]=mt()%(xxx-1)+1; ll now_score=score(t,u,ans); double now_second=now/CLOCKS_PER_SEC; double start_second=start/CLOCKS_PER_SEC; double temp=5000000000+(5000000000-0)*(now_second-start_second)/time_limit; double prob=exp((now_score-max_score)/temp); if(1.0*(double)mt()/(double)(1ll<<32)<prob){ max_score=now_score; }else{ ans[x]=h; } } rep(i,n){ cout << ans[i] << " " << ans[i] << " " << 1 << endl; } }