結果
問題 | No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance |
ユーザー | milanis48663220 |
提出日時 | 2022-10-15 00:55:12 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,761 bytes |
コンパイル時間 | 1,714 ms |
実行使用メモリ | 6,952 KB |
スコア | 1,053,684,608,971,994 |
最終ジャッジ日時 | 2022-10-15 00:57:07 |
合計ジャッジ時間 | 110,244 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,939 ms
3,940 KB |
testcase_01 | AC | 1,945 ms
3,880 KB |
testcase_02 | AC | 1,942 ms
3,876 KB |
testcase_03 | AC | 1,941 ms
3,824 KB |
testcase_04 | AC | 1,944 ms
4,076 KB |
testcase_05 | TLE | - |
testcase_06 | AC | 1,935 ms
3,840 KB |
testcase_07 | AC | 1,945 ms
3,820 KB |
testcase_08 | AC | 1,942 ms
3,888 KB |
testcase_09 | AC | 1,941 ms
3,824 KB |
testcase_10 | AC | 1,946 ms
3,940 KB |
testcase_11 | AC | 1,944 ms
3,872 KB |
testcase_12 | AC | 1,944 ms
3,868 KB |
testcase_13 | AC | 1,943 ms
3,864 KB |
testcase_14 | AC | 1,940 ms
3,892 KB |
testcase_15 | AC | 1,949 ms
3,940 KB |
testcase_16 | AC | 1,992 ms
4,072 KB |
testcase_17 | AC | 1,961 ms
3,748 KB |
testcase_18 | AC | 1,971 ms
3,944 KB |
testcase_19 | AC | 1,942 ms
3,928 KB |
testcase_20 | AC | 1,958 ms
3,892 KB |
testcase_21 | AC | 1,945 ms
3,936 KB |
testcase_22 | AC | 1,944 ms
3,880 KB |
testcase_23 | AC | 1,945 ms
4,072 KB |
testcase_24 | AC | 1,954 ms
3,788 KB |
testcase_25 | AC | 1,940 ms
3,788 KB |
testcase_26 | AC | 1,951 ms
6,952 KB |
testcase_27 | AC | 1,944 ms
4,028 KB |
testcase_28 | AC | 1,940 ms
3,892 KB |
testcase_29 | AC | 1,949 ms
3,744 KB |
testcase_30 | AC | 1,945 ms
4,904 KB |
testcase_31 | AC | 1,941 ms
4,904 KB |
testcase_32 | AC | 1,945 ms
5,160 KB |
testcase_33 | AC | 1,944 ms
5,160 KB |
testcase_34 | AC | 1,942 ms
4,900 KB |
testcase_35 | AC | 1,942 ms
4,904 KB |
testcase_36 | AC | 1,946 ms
4,904 KB |
testcase_37 | AC | 1,941 ms
4,904 KB |
testcase_38 | AC | 1,934 ms
3,824 KB |
testcase_39 | AC | 1,941 ms
4,904 KB |
testcase_40 | AC | 1,946 ms
4,900 KB |
testcase_41 | AC | 1,962 ms
4,900 KB |
testcase_42 | AC | 1,948 ms
4,904 KB |
testcase_43 | AC | 1,947 ms
4,904 KB |
testcase_44 | AC | 1,940 ms
5,156 KB |
testcase_45 | AC | 1,942 ms
5,156 KB |
testcase_46 | AC | 1,942 ms
4,900 KB |
testcase_47 | AC | 1,941 ms
4,900 KB |
testcase_48 | AC | 1,942 ms
4,904 KB |
testcase_49 | AC | 1,945 ms
4,900 KB |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <cassert> #include <random> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template<typename T> vector<vector<T>> vec2d(int n, int m, T v){ return vector<vector<T>>(n, vector<T>(m, v)); } template<typename T> vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){ return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v))); } template<typename T> void print_vector(vector<T> v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } int N, K; int t[50], u[50]; void input(){ cin >> N >> K; for(int i = 0; i < K; i++) cin >> t[i]; for(int i = 0; i < K; i++) cin >> u[i]; } int naive_simulate(int b, int m, int e, int t){ int d = 1, a = b; int x = 0; for(int i = 1; i <= t; i++){ x += d; if(x == a*d){ d *= -1; a = max(m, a-e); } } return x; } int simulate(int b, int m, int e, int t){ assert(m == b); int rem = t%(4*b); if(rem <= b){ return rem; }else if(rem <= 3*b){ return b-(rem-b); }else{ return -b+(rem-3*b); } } void test(){ for(int b = 1; b <= 100; b++){ for(int e = 1; e <= 10; e++){ for(int t = 0; t <= 100; t++){ assert(simulate(b, b, e, t) == naive_simulate(b, b, e, t)); } } } } int b[50], m[50], e[50]; ll eval(){ vector<int> x(N); double s0 = 0.0; double coef = 2e7/((double)N*(double)(N-1)); for(int i = 0; i < K; i++){ for(int j = 0; j < K; j++){ x[j] = simulate(b[j], m[j], e[j], t[j]); } for(int j = 0; j < N; j++){ for(int k = j+1; k < N; k++){ s0 += coef*abs(x[j]-x[k])/((double)(b[j]+b[k])); } } } double s1 = 0.0; for(int i = 0; i < K; i++){ for(int j = 0; j < N; j++){ x[j] = simulate(b[j], m[j], e[j], t[j]); } int max_diff = 0; for(int j = 0; j < N; j++){ for(int k = j+1; k < N; k++){ chmax(max_diff, abs(x[k]-x[j])); } } s1 += 1e7/sqrt(0.05*max_diff+1.0); } return round(s0/(double)K)*round(s1/(double)K); } const int min_b = 1, max_b = 1000000000; void solve(double time_limit, double start_temp = 1000000000.0, double end_temp = 0.5, int seed=42){ mt19937 mt; mt.seed(seed); uniform_real_distribution<float> rand_dist(0.0, 1.0); auto accept_proba = [&](int diff, double temp){ return min(1.0, exp((double)diff/temp)); }; auto randint = [&](const int l, const int r){ return mt()%(r - l) + l; }; clock_t start = clock(); for(int i = 0; i < N; i++){ b[i] = randint(1, 10); m[i] = b[i]; e[i] = 1; } ll cur_score = eval(); double temperature = start_temp; double remaining_time = time_limit - (double)(clock()-start)/CLOCKS_PER_SEC; int max_db = 5; for(int iter = 0; ; iter++){ if(true){ clock_t cur_time = clock(); remaining_time = time_limit - (double)(cur_time-start)/CLOCKS_PER_SEC; temperature = end_temp + (start_temp-end_temp) * (remaining_time/time_limit); if(remaining_time < 0.0) { debug_value(iter) break; } } int idx = randint(0, N); int db = randint(0, max_db*2)-max_db; int prev_b = b[idx]; b[idx] += db; chmax(b[idx], min_b); chmin(b[idx], max_b); m[idx] = b[idx]; ll new_score = eval(); if(accept_proba(new_score-cur_score, temperature) >= rand_dist(mt)){ cur_score = new_score; }else{ b[idx] = prev_b; m[idx] = prev_b; } } } void output(){ for(int i = 0; i < N; i++) cout << b[i] << ' ' << m[i] << ' ' << e[i] << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; input(); solve(1.9); output(); cerr << eval() << endl; }