結果
問題 | No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance |
ユーザー | milanis48663220 |
提出日時 | 2022-10-15 00:28:49 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,908 ms / 2,000 ms |
コード長 | 4,756 bytes |
コンパイル時間 | 1,555 ms |
実行使用メモリ | 6,952 KB |
スコア | 10,713,981,702,245 |
最終ジャッジ日時 | 2022-10-15 00:31:14 |
合計ジャッジ時間 | 105,398 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,857 ms
4,900 KB |
testcase_01 | AC | 1,826 ms
4,904 KB |
testcase_02 | AC | 1,864 ms
4,900 KB |
testcase_03 | AC | 1,835 ms
4,904 KB |
testcase_04 | AC | 1,841 ms
4,900 KB |
testcase_05 | AC | 1,855 ms
4,900 KB |
testcase_06 | AC | 1,848 ms
4,904 KB |
testcase_07 | AC | 1,837 ms
4,900 KB |
testcase_08 | AC | 1,847 ms
3,636 KB |
testcase_09 | AC | 1,842 ms
4,900 KB |
testcase_10 | AC | 1,860 ms
4,904 KB |
testcase_11 | AC | 1,908 ms
6,948 KB |
testcase_12 | AC | 1,856 ms
4,900 KB |
testcase_13 | AC | 1,837 ms
6,948 KB |
testcase_14 | AC | 1,853 ms
6,952 KB |
testcase_15 | AC | 1,856 ms
6,952 KB |
testcase_16 | AC | 1,844 ms
4,904 KB |
testcase_17 | AC | 1,841 ms
6,952 KB |
testcase_18 | AC | 1,837 ms
4,900 KB |
testcase_19 | AC | 1,836 ms
4,904 KB |
testcase_20 | AC | 1,846 ms
4,904 KB |
testcase_21 | AC | 1,835 ms
4,900 KB |
testcase_22 | AC | 1,842 ms
4,904 KB |
testcase_23 | AC | 1,841 ms
6,948 KB |
testcase_24 | AC | 1,842 ms
4,904 KB |
testcase_25 | AC | 1,867 ms
4,900 KB |
testcase_26 | AC | 1,822 ms
4,904 KB |
testcase_27 | AC | 1,849 ms
4,900 KB |
testcase_28 | AC | 1,847 ms
6,952 KB |
testcase_29 | AC | 1,838 ms
6,948 KB |
testcase_30 | AC | 1,857 ms
4,904 KB |
testcase_31 | AC | 1,839 ms
6,948 KB |
testcase_32 | AC | 1,839 ms
4,900 KB |
testcase_33 | AC | 1,848 ms
4,904 KB |
testcase_34 | AC | 1,839 ms
6,948 KB |
testcase_35 | AC | 1,837 ms
4,904 KB |
testcase_36 | AC | 1,851 ms
4,904 KB |
testcase_37 | AC | 1,875 ms
6,948 KB |
testcase_38 | AC | 1,839 ms
4,904 KB |
testcase_39 | AC | 1,847 ms
4,904 KB |
testcase_40 | AC | 1,849 ms
6,948 KB |
testcase_41 | AC | 1,836 ms
6,952 KB |
testcase_42 | AC | 1,842 ms
4,904 KB |
testcase_43 | AC | 1,848 ms
4,908 KB |
testcase_44 | AC | 1,856 ms
6,948 KB |
testcase_45 | AC | 1,849 ms
4,900 KB |
testcase_46 | AC | 1,852 ms
4,900 KB |
testcase_47 | AC | 1,851 ms
4,904 KB |
testcase_48 | AC | 1,864 ms
6,948 KB |
testcase_49 | AC | 1,854 ms
4,908 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 < n; 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 = 5.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, 1000000); 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 = 100000; for(int iter = 0; ; iter++){ if(iter%100 == 0){ 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)){ 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.8); output(); // cerr << eval() << endl; }