結果
| 問題 |
No.1318 ABCD quadruplets
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:43:52 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 881 bytes |
| コンパイル時間 | 281 ms |
| コンパイル使用メモリ | 82,364 KB |
| 実行使用メモリ | 237,060 KB |
| 最終ジャッジ日時 | 2025-06-12 16:44:12 |
| 合計ジャッジ時間 | 4,525 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 1 -- * 19 |
ソースコード
def main():
import sys
from collections import defaultdict
N, M = map(int, sys.stdin.readline().split())
# Initialize DP: dp[T][S] = count
dp = defaultdict(lambda: defaultdict(int))
dp[0][0] = 1
# Process each of the four variables
for _ in range(4):
new_dp = defaultdict(lambda: defaultdict(int))
for T in dp:
for S in dp[T]:
count = dp[T][S]
for x in range(0, M + 1):
new_T = T + x
new_S = S + x * x
new_dp[new_T][new_S] += count
dp = new_dp
# Compute the result
f = [0] * (N + 1)
for T in dp:
for S in dp[T]:
E = (T * T + S) // 2
if E <= N:
f[E] += dp[T][S]
# Output the result
for e in f:
print(e)
if __name__ == '__main__':
main()
gew1fw