結果

問題 No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance
ユーザー 👑 potato167
提出日時 2022-10-15 01:18:39
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,975 ms / 2,000 ms
コード長 3,211 bytes
コンパイル時間 2,140 ms
実行使用メモリ 6,952 KB
スコア 1,319,723,419,704,686
最終ジャッジ日時 2022-10-15 01:20:29
合計ジャッジ時間 108,398 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll ILL=2167167167167167167;
const int INF=2100000000;
const ll mod=1e9+7;
#define rep(i,a) for (int i=0;i<a;i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";}
template<class T> void vec_out(vector<T> &p){for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}
template<class T> T min(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;}
template<class T> T max(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;}

//https://ei1333.github.io/library/other/xor-shift.cpp.html
struct XorShift {
private:
  constexpr static double R = 1.0 / 0xffffffff;
  uint64_t x;

public:
  explicit XorShift(uint64_t seed = 88172645463325252ull) : x(seed) {}

  template< typename T = uint64_t >
  inline T get() { // [0, 2^64)
    x ^= x << 7ull;
    x ^= x >> 9ull;
    return x;
  }

  inline uint32_t get(uint32_t r) { // [0, r)
    return ((uint64_t) get< uint32_t >() * r) >> 32ull;
  }

  inline uint32_t get(uint32_t l, uint32_t r) { // [l, r)
    return l + get(r - l);
  }

  inline double probability() { // [0.0, 1.0]
    return get< uint32_t >() * R;
  }
};


template<class T>
void shuffle_vector(vector<T> &p,XorShift &table){
	int L=p.size();
	for(int i=0;i<L;i++){
		int ind=table.get(i,L);
		swap(p[ind],p[i]);
	}
	return ;
}

void solve();
// oddloop
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t=1;
	//cin>>t;
	rep(i,t) solve();
}

void solve(){
	int N,K;
	cin>>N>>K;
	XorShift table(167);
	vector<int> p={2,3,4,5,6,7,8};
	int M=p.size();
	ld ans=0;
	vector<int> val(N);
	vector<int> T(K),U(K);
	rep(i,K) cin>>T[i];
	rep(i,K) cin>>U[i];
	auto f=[](int a,int time)->int{
		time%=(a*4);
		if(time<=a) return time;
		if(time+a>=a*4) return time-a*4;
		return a*2-time;
	};
	while(clock()<1.9*CLOCKS_PER_SEC){
		vector<int> tmp(M+1);
		tmp[M]=N;
		rep(i,M-1) tmp[i]=table.get(N+1);
		So(tmp);
		vector<int> q;
		rep(i,M){
			q.push_back(tmp[i+1]-tmp[i]);
		}
		ld tmp1=0,tmp2=0;
		rep(k,K){
			rep(i,M) rep(j,i){
				tmp1+=(ld)((q[j]*q[i]))*(ld)(abs(f(p[i],T[k])-f(p[j],T[k])))/(ld)(p[i]+p[j]);
			}
		}
		rep(k,K){
			int A=INF,B=-INF;
			rep(i,M){
				if(q[i]==0) continue;
				int C=f(p[i],U[k]);
				chmin(A,C);
				chmax(B,C);
			}
			tmp2+=1/sqrtl(1+(ld)(B-A)/(ld)(20));
		}
		tmp1*=tmp2;
		if(chmax(ans,tmp1))val=q;
	}
	rep(i,M){
		rep(_,val[i]) cout<<p[i]<<" "<<p[i]<<" "<<p[i]<<"\n";
	}
}
0