結果
問題 | No.2222 Respawn |
ユーザー | chineristAC |
提出日時 | 2023-02-17 23:07:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 145 ms / 2,000 ms |
コード長 | 1,695 bytes |
コンパイル時間 | 178 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 95,616 KB |
最終ジャッジ日時 | 2024-07-19 14:18:56 |
合計ジャッジ時間 | 4,061 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
55,552 KB |
testcase_01 | AC | 51 ms
55,552 KB |
testcase_02 | AC | 51 ms
55,680 KB |
testcase_03 | AC | 49 ms
55,680 KB |
testcase_04 | AC | 52 ms
55,552 KB |
testcase_05 | AC | 51 ms
55,552 KB |
testcase_06 | AC | 50 ms
55,552 KB |
testcase_07 | AC | 48 ms
55,552 KB |
testcase_08 | AC | 52 ms
56,832 KB |
testcase_09 | AC | 51 ms
56,576 KB |
testcase_10 | AC | 53 ms
56,832 KB |
testcase_11 | AC | 51 ms
55,808 KB |
testcase_12 | AC | 51 ms
56,704 KB |
testcase_13 | AC | 92 ms
82,560 KB |
testcase_14 | AC | 91 ms
80,896 KB |
testcase_15 | AC | 85 ms
75,648 KB |
testcase_16 | AC | 91 ms
79,872 KB |
testcase_17 | AC | 85 ms
75,648 KB |
testcase_18 | AC | 105 ms
89,344 KB |
testcase_19 | AC | 109 ms
91,008 KB |
testcase_20 | AC | 103 ms
88,832 KB |
testcase_21 | AC | 109 ms
90,624 KB |
testcase_22 | AC | 109 ms
90,624 KB |
testcase_23 | AC | 120 ms
95,616 KB |
testcase_24 | AC | 123 ms
95,488 KB |
testcase_25 | AC | 124 ms
95,360 KB |
testcase_26 | AC | 124 ms
95,616 KB |
testcase_27 | AC | 122 ms
95,360 KB |
testcase_28 | AC | 106 ms
88,192 KB |
testcase_29 | AC | 109 ms
89,728 KB |
testcase_30 | AC | 105 ms
88,192 KB |
testcase_31 | AC | 83 ms
82,944 KB |
testcase_32 | AC | 145 ms
86,400 KB |
ソースコード
import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import gcd,log input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N = int(input()) S = input().rstrip() S += "#" dp = [10**15] * N dp[N-1] = 0 dp_save = [0] * N dp_save_p = [0] * N dp_back_p = [0] * N dp_back_e = [0] * N for i in range(N-1)[::-1]: if S[i]=="#": continue if i+1 <= N and S[i+1]==".": if i+1 != N-1: dp_back_p[i] += dp_back_p[i+1]/3 dp_back_e[i] += (dp_back_p[i+1]+dp_back_e[i+1])/3 dp_save[i] += 1/9 * (2+dp[i+1]) + 1/3 * (dp_save_p[i+1]+dp_save[i+1]) dp_save_p[i] += 1/9 + 1/3 * dp_save_p[i+1] else: dp_save[i] += 1/3 dp_save_p[i] += 1/3 elif i+1 <= N: dp_back_p[i] += 1/3 dp_back_e[i] += 1/3 if i+2 <= N and S[i+2]==".": if i+2 != N-1: dp_back_p[i] += dp_back_p[i+2]/3 dp_back_e[i] += (dp_back_p[i+2]+dp_back_e[i+2])/3 dp_save[i] += 1/9 * (2+dp[i+2]) + 1/3 * (dp_save_p[i+2]+dp_save[i+2]) dp_save_p[i] += 1/9 + 1/3 * dp_save_p[i+2] else: dp_save[i] += 1/3 dp_save_p[i] += 1/3 elif i+2 <= N: dp_back_p[i] += 1/3 dp_back_e[i] += 1/3 """ dp[i] = 1/3 * (1+dp[i]) + dp_save[i] + dp_back_p[i] * dp[i] + dp_back_e[i] """ #print(dp_save[i],dp_back_e[i],dp_back_p[i]) #print(dp_save_p[i]+dp_back_p[i]) dp[i] = (1/3+dp_save[i]+dp_back_e[i]) / (2/3-dp_back_p[i]) #print(dp[i]) print(dp[0])