結果
| 問題 |
No.1318 ABCD quadruplets
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:31:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,053 bytes |
| コンパイル時間 | 155 ms |
| コンパイル使用メモリ | 82,584 KB |
| 実行使用メモリ | 86,236 KB |
| 最終ジャッジ日時 | 2025-06-12 16:31:40 |
| 合計ジャッジ時間 | 4,981 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 TLE * 1 -- * 18 |
ソースコード
import sys
from collections import defaultdict
def main():
input = sys.stdin.read().split()
N = int(input[0])
M = int(input[1])
# Precompute s_t_dict for c and d
s_t_dict = defaultdict(lambda: defaultdict(int))
for c in range(M + 1):
for d in range(M + 1):
s = c + d
t = c * c + c * d + d * d
s_t_dict[s][t] += 1
ans = [0] * (N + 1)
max_s = 2 * M
for a in range(M + 1):
for b in range(M + 1):
k = a + b
m = a * a + a * b + b * b
for s in range(max_s + 1):
if s not in s_t_dict:
continue
ks = k * s
m_ks = m + ks
if m_ks > N:
continue
t_dict = s_t_dict[s]
for t, count in t_dict.items():
n = m_ks + t
if n <= N:
ans[n] += count
for count in ans:
print(count)
if __name__ == '__main__':
main()
gew1fw