結果
問題 | No.1398 調和の魔法陣 (構築) |
ユーザー |
![]() |
提出日時 | 2021-02-19 23:18:38 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 693 ms / 3,153 ms |
コード長 | 1,144 bytes |
コンパイル時間 | 82 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 46,992 KB |
最終ジャッジ日時 | 2024-09-16 22:52:13 |
合計ジャッジ時間 | 39,682 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
import sysimport numpy as npreadline = sys.stdin.readlineread = sys.stdin.readw, h, x = map(int, readline().split())if x <= 9:ans = np.zeros((h,w), dtype=np.int64)f = [1,0,0]ans[f[h%3]::3,f[w%3]::3] = xfor l in ans:print(''.join(map(str, l)))sys.exit()if x <= 18:if w % 3 == 2:ans = np.zeros((h,w), dtype=np.int64)f = [1,0,0]ans[f[h%3]::3,::3] = 9ans[f[h%3]::3,1::3] = x - 9for l in ans:print(''.join(map(str, l)))sys.exit()if h % 3 == 2:ans = np.zeros((h,w), dtype=np.int64)f = [1,0,0]ans[::3,f[w%3]::3] = 9ans[1::3,f[w%3]::3] = x - 9for l in ans:print(''.join(map(str, l)))sys.exit()if x <= 36 and h % 3 == 2 and w % 3 == 2:ans = np.zeros((h,w), dtype=np.int64)if x <= 27:a = np.array([[9,9,0],[x-18,0,0],[0,0,0]], dtype=np.int64)else:a = np.array([[9,9,0],[9,x-27,0],[0,0,0]], dtype=np.int64)ans = np.tile(a,((h+1)//3,(w+1)//3))[:-1,:-1]for l in ans:print(''.join(map(str, l)))sys.exit()print(-1)