結果
問題 | No.1398 調和の魔法陣 (構築) |
ユーザー | tamato |
提出日時 | 2021-02-19 22:24:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 91 ms / 3,153 ms |
コード長 | 3,571 bytes |
コンパイル時間 | 520 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 79,232 KB |
最終ジャッジ日時 | 2024-09-16 20:26:51 |
合計ジャッジ時間 | 29,179 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline W, H, X = map(int, input().split()) if X == 0: for _ in range(H): print("0" * W) exit() if X > 36: print(-1) exit() a = min(X, 9) X -= a b = min(X, 9) X -= b c = min(X, 9) X -= c d = X ans = [[0] * W for _ in range(H)] if H%3 == 2 and W%3 == 2: for h in range(H): for w in range(W): if h%3 == 0 and w%3 == 0: ans[h][w] = a elif h%3 == 0 and w%3 == 1: ans[h][w] = b elif h%3 == 1 and w%3 == 0: ans[h][w] = c elif h%3 == 1 and w%3 == 1: ans[h][w] = d for h in range(H): print("".join(map(str, ans[h]))) elif H%3 == 2 and W%3 == 1: if c: print(-1) exit() for h in range(H): for w in range(W): if h%3 == 0 and w%3 == 0: ans[h][w] = a elif h%3 == 1 and w%3 == 0: ans[h][w] = b for h in range(H): print("".join(map(str, ans[h]))) elif H%3 == 1 and W%3 == 2: if c: print(-1) exit() for h in range(H): for w in range(W): if h%3 == 0 and w%3 == 0: ans[h][w] = a elif h%3 == 0 and w%3 == 1: ans[h][w] = b for h in range(H): print("".join(map(str, ans[h]))) elif H%3 == 1 and W%3 == 1: if b: print(-1) exit() for h in range(H): for w in range(W): if h%3 == 0 and w%3 == 0: ans[h][w] = a for h in range(H): print("".join(map(str, ans[h]))) elif H%3 == 1 and W%3 == 0: if b: print(-1) exit() for h in range(H): for w in range(W): if h%3 == 0 and w%3 == 1: ans[h][w] = a for h in range(H): print("".join(map(str, ans[h]))) elif H%3 == 0 and W%3 == 1: if b: print(-1) exit() for h in range(H): for w in range(W): if h%3 == 1 and w%3 == 0: ans[h][w] = a for h in range(H): print("".join(map(str, ans[h]))) elif H%3 == 0 and W%3 == 0: if b: print(-1) exit() for h in range(H): for w in range(W): if h%3 == 1 and w%3 == 1: ans[h][w] = a for h in range(H): print("".join(map(str, ans[h]))) elif H%3 == 2 and W%3 == 0: if c: print(-1) exit() for h in range(H): for w in range(W): if h%3 == 0 and w%3 == 1: ans[h][w] = a elif h%3 == 1 and w%3 == 1: ans[h][w] = b for h in range(H): print("".join(map(str, ans[h]))) elif H%3 == 0 and W%3 == 2: if c: print(-1) exit() for h in range(H): for w in range(W): if h%3 == 1 and w%3 == 0: ans[h][w] = a elif h%3 == 1 and w%3 == 1: ans[h][w] = b for h in range(H): print("".join(map(str, ans[h]))) if __name__ == '__main__': main()