結果
問題 | No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance |
ユーザー | SSRS |
提出日時 | 2022-10-14 23:47:45 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 3,811 bytes |
コンパイル時間 | 1,945 ms |
実行使用メモリ | 3,540 KB |
スコア | 1,025,872,308,943,214 |
最終ジャッジ日時 | 2022-10-14 23:47:58 |
合計ジャッジ時間 | 10,505 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 15 ms
3,508 KB |
testcase_01 | AC | 15 ms
3,452 KB |
testcase_02 | AC | 15 ms
3,528 KB |
testcase_03 | AC | 15 ms
3,540 KB |
testcase_04 | AC | 15 ms
3,512 KB |
testcase_05 | AC | 15 ms
3,456 KB |
testcase_06 | AC | 15 ms
3,452 KB |
testcase_07 | AC | 15 ms
3,432 KB |
testcase_08 | AC | 14 ms
3,452 KB |
testcase_09 | AC | 15 ms
3,484 KB |
testcase_10 | AC | 15 ms
3,528 KB |
testcase_11 | AC | 15 ms
3,456 KB |
testcase_12 | AC | 15 ms
3,532 KB |
testcase_13 | AC | 15 ms
3,388 KB |
testcase_14 | AC | 15 ms
3,528 KB |
testcase_15 | AC | 15 ms
3,536 KB |
testcase_16 | AC | 16 ms
3,456 KB |
testcase_17 | AC | 15 ms
3,456 KB |
testcase_18 | AC | 15 ms
3,392 KB |
testcase_19 | AC | 15 ms
3,452 KB |
testcase_20 | AC | 15 ms
3,540 KB |
testcase_21 | AC | 15 ms
3,508 KB |
testcase_22 | AC | 15 ms
3,536 KB |
testcase_23 | AC | 15 ms
3,540 KB |
testcase_24 | AC | 15 ms
3,452 KB |
testcase_25 | AC | 17 ms
3,452 KB |
testcase_26 | AC | 16 ms
3,484 KB |
testcase_27 | AC | 15 ms
3,456 KB |
testcase_28 | AC | 15 ms
3,388 KB |
testcase_29 | AC | 15 ms
3,388 KB |
testcase_30 | AC | 14 ms
3,432 KB |
testcase_31 | AC | 15 ms
3,532 KB |
testcase_32 | AC | 15 ms
3,432 KB |
testcase_33 | AC | 16 ms
3,488 KB |
testcase_34 | AC | 16 ms
3,532 KB |
testcase_35 | AC | 15 ms
3,392 KB |
testcase_36 | AC | 15 ms
3,532 KB |
testcase_37 | AC | 15 ms
3,528 KB |
testcase_38 | AC | 15 ms
3,484 KB |
testcase_39 | AC | 15 ms
3,452 KB |
testcase_40 | AC | 15 ms
3,456 KB |
testcase_41 | AC | 16 ms
3,384 KB |
testcase_42 | AC | 16 ms
3,420 KB |
testcase_43 | AC | 16 ms
3,436 KB |
testcase_44 | AC | 15 ms
3,532 KB |
testcase_45 | AC | 15 ms
3,480 KB |
testcase_46 | AC | 16 ms
3,540 KB |
testcase_47 | AC | 16 ms
3,540 KB |
testcase_48 | AC | 16 ms
3,484 KB |
testcase_49 | AC | 16 ms
3,508 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; long long ap(long long a, long long d, long long n){ return (2 * a + (n - 1) * d) * n / 2; } int get(int B, int M, int E, int t){ int cnt = (B - M) / E + 1; long long T = ap(B * 2, -E * 2, cnt); if (t <= T){ int tv = 0, fv = (B - M) / E + 1; while (fv - tv > 1){ int mid = (tv + fv) / 2; if (ap(B * 2, -E * 2, mid) <= t){ tv = mid; } else { fv = mid; } } long long t2 = ap(B * 2, -E * 2, tv); t -= t2; if (tv % 2 == 0){ int a = B - E * tv; if (t <= a){ return t; } else { return a * 2 - t; } } else { int a = B - E * tv; if (t <= a){ return -t; } else { return -(a * 2 - t); } } } else { t -= T; t %= M * 4; int ans; if (t < M){ ans = t; } else if (t < M * 3){ ans = M * 2 - t; } else { ans = t - M * 4; } if (cnt % 2 == 1){ ans *= -1; } return ans; } } long long get_score(int N, int K, vector<int> &T, vector<int> &U, vector<int> &B, vector<int> &M, vector<int> &E){ long long S1 = 0, S2 = 0; for (int i = 0; i < K; i++){ vector<int> X(N); for (int j = 0; j < N; j++){ X[j] = get(B[j], M[j], E[j], T[i]); } double ans = 0; for (int j = 0; j < N; j++){ for (int k = j + 1; k < N; k++){ ans += (double) abs(X[j] - X[k]) / (B[j] + B[k]); } } ans *= 20000000; ans /= N; ans /= N - 1; S1 += ans; } for (int i = 0; i < K; i++){ vector<int> X(N); for (int j = 0; j < N; j++){ X[j] = get(B[j], M[j], E[j], U[i]); } int mx = 0; for (int j = 0; j < N; j++){ for (int k = j + 1; k < N; k++){ mx = max(mx, abs(X[k] - X[j])); } } double ans = (double) mx / 20 + 1; ans = 10000000 / sqrt(ans); S2 += ans; } S1 /= K; S2 /= K; return S1 * S2; } void generate(int K, vector<int> &T, vector<int> &U){ int D = 200; vector<int> G(K * 2 + 1); mt19937 mt(chrono::steady_clock::now().time_since_epoch().count()); uniform_real_distribution<> dist(0.0, 1.0); while (true){ vector<double> F(K * 2, 0); for (int i = 0; i < K * 2; i++){ while (F[i] == 0){ F[i] = dist(mt); } } G[0] = 0; bool ok = true; for (int i = 0; i < K * 2; i++){ int c = D / F[i]; if (G[i] + c > 1000000000){ ok = false; break; } G[i + 1] = G[i] + c; } if (ok){ break; } } T.resize(K); U.resize(K); for (int i = 0; i < K; i++){ T[i] = G[i * 2 + 1]; U[i] = G[i * 2 + 2]; } if (mt() % 2 == 0){ swap(T, U); } } void solve(int N, int K, vector<int> &T, vector<int> &U, vector<int> &B, vector<int> &M, vector<int> &E){ long long mx = 0; mt19937 mt(0); for (int i = 0; i < 50; i++){ vector<int> B2(N), M2(N), E2(N); for (int j = 0; j < N; j++){ B2[j] = mt() % 10 + 1; M2[j] = mt() % B2[j] + 1; E2[j] = mt() % 3 + 1; } long long score = get_score(N, K, T, U, B2, M2, E2); if (score > mx){ mx = score; B = B2; M = M2; E = E2; } } } long long test(int N, int K){ long long ans = 0; for (int i = 0; i < 50; i++){ vector<int> T, U; generate(K, T, U); vector<int> B, M, E; solve(N, K, T, U, B, M, E); ans += get_score(N, K, T, U, B, M, E); } return ans; } int main(){ int N = 50; int K = 50; //cout << test(N, K) << endl; vector<int> T(N); for (int i = 0; i < N; i++){ cin >> T[i]; } vector<int> U(N); for (int i = 0; i < N; i++){ cin >> U[i]; } vector<int> B, M, E; solve(N, K, T, U, B, M, E); for (int i = 0; i < N; i++){ cout << B[i] << ' ' << M[i] << ' ' << E[i] << endl; } }