結果
問題 | No.1398 調和の魔法陣 (構築) |
ユーザー | aaaaaaaaaa2230 |
提出日時 | 2021-02-20 10:57:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 83 ms / 3,153 ms |
コード長 | 2,030 bytes |
コンパイル時間 | 265 ms |
コンパイル使用メモリ | 81,888 KB |
実行使用メモリ | 81,840 KB |
最終ジャッジ日時 | 2024-09-17 12:52:34 |
合計ジャッジ時間 | 23,711 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
w,h,x = map(int,input().split()) def ans(w,h,x): m = [[-1]] if x > 36: return m l = [[0]*w for i in range(h)] if h%3 == 0 and w%3 == 0: if x > 9: return m for i in range(1,h,3): for j in range(1,w,3): l[i][j] = x if h%3 == 0 and w % 3 == 1: if x > 9: return m for i in range(1,h,3): for j in range(0,w,3): l[i][j] = x if h%3 == 1 and w % 3 == 0: if x > 9: return m for i in range(0,h,3): for j in range(1,w,3): l[i][j] = x if h%3 == 1 and w % 3 == 1: if x > 9: return m for i in range(0,h,3): for j in range(0,w,3): l[i][j] = x if h%3 == 0 and w % 3 == 2: if x > 18: return m for i in range(1,h,3): for j in range(0,w,3): l[i][j] = min(9,x) l[i][j+1] = max(0,x-min(9,x)) if h%3 == 2 and w % 3 == 0: if x > 18: return m for i in range(0,h,3): for j in range(1,w,3): l[i][j] = min(9,x) l[i+1][j] = max(0,x-min(9,x)) if h%3 == 1 and w % 3 == 2: if x > 18: return m for i in range(0,h,3): for j in range(0,w,3): l[i][j] = min(9,x) l[i][j+1] = max(0,x-min(9,x)) if h%3 == 2 and w % 3 == 1: if x > 18: return m for i in range(0,h,3): for j in range(0,w,3): l[i][j] = min(9,x) l[i+1][j] = max(0,x-min(9,x)) if h%3 == 2 and w % 3 == 2: a = min(9,x) b = min(9,x-a) c = min(9,x-a-b) d = x-a-b-c for i in range(0,h,3): for j in range(0,w,3): l[i][j] = a l[i+1][j] = b l[i][j+1] = c l[i+1][j+1] = d return l for i in ans(w,h,x): print(*i,sep="")