結果
問題 | No.1967 Sugoroku Optimization |
ユーザー | chineristAC |
提出日時 | 2022-06-03 21:42:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 173 ms / 2,000 ms |
コード長 | 1,966 bytes |
コンパイル時間 | 205 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 113,664 KB |
最終ジャッジ日時 | 2024-09-21 02:33:12 |
合計ジャッジ時間 | 4,141 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
67,456 KB |
testcase_01 | AC | 67 ms
67,200 KB |
testcase_02 | AC | 67 ms
67,200 KB |
testcase_03 | AC | 171 ms
113,664 KB |
testcase_04 | AC | 173 ms
113,408 KB |
testcase_05 | AC | 163 ms
113,408 KB |
testcase_06 | AC | 165 ms
113,024 KB |
testcase_07 | AC | 163 ms
112,896 KB |
testcase_08 | AC | 137 ms
92,288 KB |
testcase_09 | AC | 170 ms
113,408 KB |
testcase_10 | AC | 114 ms
91,904 KB |
testcase_11 | AC | 133 ms
92,288 KB |
testcase_12 | AC | 167 ms
113,152 KB |
testcase_13 | AC | 141 ms
92,416 KB |
testcase_14 | AC | 165 ms
113,408 KB |
testcase_15 | AC | 118 ms
91,904 KB |
testcase_16 | AC | 110 ms
91,520 KB |
testcase_17 | AC | 89 ms
78,976 KB |
testcase_18 | AC | 89 ms
79,232 KB |
testcase_19 | AC | 66 ms
67,456 KB |
testcase_20 | AC | 169 ms
113,408 KB |
testcase_21 | AC | 65 ms
66,944 KB |
testcase_22 | AC | 169 ms
113,536 KB |
testcase_23 | AC | 169 ms
113,152 KB |
ソースコード
class UnionFindVerSize(): def __init__(self, N): self._parent = [n for n in range(0, N)] self._size = [1] * N self.group = N def find_root(self, x): if self._parent[x] == x: return x self._parent[x] = self.find_root(self._parent[x]) stack = [x] while self._parent[stack[-1]]!=stack[-1]: stack.append(self._parent[stack[-1]]) for v in stack: self._parent[v] = stack[-1] return self._parent[x] def unite(self, x, y): gx = self.find_root(x) gy = self.find_root(y) if gx == gy: return self.group -= 1 if self._size[gx] < self._size[gy]: self._parent[gx] = gy self._size[gy] += self._size[gx] return gy else: self._parent[gy] = gx self._size[gx] += self._size[gy] return gx def get_size(self, x): return self._size[self.find_root(x)] def is_same_group(self, x, y): return self.find_root(x) == self.find_root(y) import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) def cmb(n, r, mod): if ( r<0 or r>n ): return 0 return (g1[n] * g2[r] % mod) * g2[n-r] % mod mod = 998244353 N = 2*10**5 g1 = [1]*(N+1) g2 = [1]*(N+1) inverse = [1]*(N+1) for i in range( 2, N + 1 ): g1[i]=( ( g1[i-1] * i ) % mod ) inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod ) g2[i]=( (g2[i-1] * inverse[i]) % mod ) inverse[0]=0 N,K = mi() dp = [[0 for j in range(N+1)] for i in range(N+1)] dp[0][0] = 1 for k in range(1,N+1): dp[k][0] = 1 t = 0 for n in range(1,N+1): t += dp[k-1][n-1] t %= mod dp[k][n] = t * inverse[n] % mod print(dp[K][N])