結果
問題 | No.1513 simple 門松列 problem |
ユーザー | mkawa2 |
提出日時 | 2023-10-03 16:59:22 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 717 ms / 3,000 ms |
コード長 | 1,987 bytes |
コンパイル時間 | 460 ms |
コンパイル使用メモリ | 82,592 KB |
実行使用メモリ | 79,968 KB |
最終ジャッジ日時 | 2024-07-26 14:08:49 |
合計ジャッジ時間 | 5,820 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
53,372 KB |
testcase_01 | AC | 40 ms
53,200 KB |
testcase_02 | AC | 717 ms
79,968 KB |
testcase_03 | AC | 51 ms
63,588 KB |
testcase_04 | AC | 39 ms
53,084 KB |
testcase_05 | AC | 53 ms
65,440 KB |
testcase_06 | AC | 60 ms
68,248 KB |
testcase_07 | AC | 51 ms
64,292 KB |
testcase_08 | AC | 55 ms
66,544 KB |
testcase_09 | AC | 40 ms
53,796 KB |
testcase_10 | AC | 40 ms
54,764 KB |
testcase_11 | AC | 39 ms
53,088 KB |
testcase_12 | AC | 40 ms
53,976 KB |
testcase_13 | AC | 40 ms
53,556 KB |
testcase_14 | AC | 660 ms
79,544 KB |
testcase_15 | AC | 687 ms
79,752 KB |
testcase_16 | AC | 700 ms
79,924 KB |
testcase_17 | AC | 472 ms
79,304 KB |
testcase_18 | AC | 210 ms
79,612 KB |
testcase_19 | AC | 69 ms
69,732 KB |
testcase_20 | AC | 155 ms
77,500 KB |
ソースコード
import sys sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 63) # md = 10**9+7 md = 998244353 n, k = LI() c = [[0]*k for _ in range(k)] t = [[0]*k for _ in range(k)] sc = [[0]*k for _ in range(k+1)] st = [[0]*k for _ in range(k+1)] pc = [[0]*k for _ in range(k)] pt = [[0]*k for _ in range(k)] psc = [[0]*k for _ in range(k+1)] pst = [[0]*k for _ in range(k+1)] for a in range(k): for b in range(k): if a == b: continue c[a][b] = 1 t[a][b] = a+b sc[a+1][b] = sc[a][b]+1 st[a+1][b] = st[a][b]+a+b for _ in range(n-2): c, t, sc, st, pc, pt, psc, pst = pc, pt, psc, pst, c, t, sc, st for a in range(k): for b in range(k): if a == b: continue if a < b: c[a][b] = psc[k][a]-psc[a+1][a]-pc[b][a] t[a][b] = pst[k][a]-pst[a+1][a]-pt[b][a]+b*c[a][b]%md else: c[a][b] = psc[a][a]-pc[b][a] t[a][b] = pst[a][a]-pt[b][a]+b*c[a][b]%md c[a][b] %= md t[a][b] %= md sc[a+1][b] = c[a][b]+sc[a][b] st[a+1][b] = t[a][b]+st[a][b] sc[a+1][b] %= md st[a+1][b] %= md x = y = 0 for a in range(k): for b in range(k): x += c[a][b] y += t[a][b] x %= md y %= md print(x, y)