結果
問題 | No.2222 Respawn |
ユーザー | SSRS |
提出日時 | 2023-02-17 22:19:12 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,797 bytes |
コンパイル時間 | 1,579 ms |
コンパイル使用メモリ | 170,632 KB |
実行使用メモリ | 18,208 KB |
最終ジャッジ日時 | 2024-07-19 13:28:05 |
合計ジャッジ時間 | 5,174 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
13,884 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 6 ms
6,944 KB |
testcase_09 | AC | 4 ms
6,940 KB |
testcase_10 | AC | 6 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 4 ms
6,944 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ cout << fixed << setprecision(20); int N; cin >> N; string S; cin >> S; S += '#'; vector<double> dp_gameover_p(N, 0); vector<double> dp_gameover_pe(N, 0); vector<double> dp_goal_p(N, 0); vector<double> dp_goal_pe(N, 0); dp_goal_p[N - 1] = 1; for (int i = N - 2; i >= 0; i--){ if (S[i] == '.'){ for (int j = i + 1; j <= i + 2; j++){ if (S[j] == '#'){ dp_gameover_p[i] += (double) 1 / 3; dp_gameover_pe[i] += (double) 1 / 3; } else { dp_gameover_p[i] += dp_gameover_p[j] / 3; dp_gameover_pe[i] += (dp_gameover_p[j] + dp_gameover_pe[j]) / 3; dp_goal_p[i] += dp_goal_p[j] / 3; dp_goal_pe[i] += (dp_goal_p[j] + dp_goal_pe[j]) / 3; } } } } vector<double> dp(N, 0); for (int i = N - 2; i >= 0; i--){ if (S[i] == '.'){ double gameover_p = dp_gameover_p[i] + (double) 1 / 3; double gameover_pe = dp_gameover_pe[i] + (double) 1 / 3; dp[i] += (1 / (1 - gameover_p) - 1) * (gameover_pe / gameover_p); double goal_rel = dp_goal_p[i] / (1 - gameover_p); dp[i] += goal_rel * (dp_goal_pe[i] / dp_goal_p[i]); vector<double> dp2_p(N, 0); vector<double> dp2_pe(N, 0); dp2_p[i] = 1; for (int j = i; j < N; j++){ if (S[j] == '.'){ for (int k = j + 1; k <= j + 2; k++){ if (S[k] == '.'){ dp2_p[k] += dp2_p[j] / 3; dp2_pe[k] += (dp2_p[j] + dp2_pe[j]) / 3; } } } } for (int j = i + 1; j < N - 1; j++){ if (S[j] == '.'){ dp[i] += (dp2_pe[j] / dp2_p[j] + 1 + dp[j]) * dp2_p[j] / 3 / (1 - gameover_p); } } } } cout << dp[0] << endl; }