結果
問題 | No.2222 Respawn |
ユーザー | SSRS |
提出日時 | 2023-02-17 23:34:20 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 114 ms / 2,000 ms |
コード長 | 1,518 bytes |
コンパイル時間 | 1,420 ms |
コンパイル使用メモリ | 169,656 KB |
実行使用メモリ | 14,848 KB |
最終ジャッジ日時 | 2024-07-19 14:45:36 |
合計ジャッジ時間 | 2,728 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 13 ms
11,264 KB |
testcase_14 | AC | 9 ms
8,960 KB |
testcase_15 | AC | 5 ms
6,272 KB |
testcase_16 | AC | 8 ms
8,320 KB |
testcase_17 | AC | 6 ms
6,016 KB |
testcase_18 | AC | 17 ms
14,848 KB |
testcase_19 | AC | 16 ms
14,720 KB |
testcase_20 | AC | 17 ms
14,592 KB |
testcase_21 | AC | 16 ms
14,720 KB |
testcase_22 | AC | 17 ms
14,720 KB |
testcase_23 | AC | 19 ms
14,720 KB |
testcase_24 | AC | 20 ms
14,720 KB |
testcase_25 | AC | 19 ms
14,720 KB |
testcase_26 | AC | 19 ms
14,592 KB |
testcase_27 | AC | 19 ms
14,592 KB |
testcase_28 | AC | 23 ms
14,720 KB |
testcase_29 | AC | 23 ms
14,720 KB |
testcase_30 | AC | 24 ms
14,720 KB |
testcase_31 | AC | 15 ms
14,720 KB |
testcase_32 | AC | 114 ms
14,720 KB |
ソースコード
#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); vector<double> dp2_p(N, 0), dp2_pe(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] += gameover_pe / (1 - gameover_p); dp[i] += dp_goal_pe[i] / (1 - gameover_p); for (int j = i + 1; j <= i + 2; j++){ if (S[j] == '.' && j < N - 1){ dp2_p[i] += (double) 1 / 9; dp2_pe[i] += (2 + dp[j]) / 9; dp2_p[i] += dp2_p[j] / 3; dp2_pe[i] += (dp2_p[j] + dp2_pe[j]) / 3; } } dp[i] += dp2_pe[i] / (1 - gameover_p); } } cout << dp[0] << endl; }