結果
| 問題 | No.1398 調和の魔法陣 (構築) | 
| コンテスト | |
| ユーザー |  ayaoni | 
| 提出日時 | 2021-02-19 22:48:30 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 42 ms / 3,153 ms | 
| コード長 | 2,009 bytes | 
| コンパイル時間 | 166 ms | 
| コンパイル使用メモリ | 82,208 KB | 
| 実行使用メモリ | 55,452 KB | 
| 最終ジャッジ日時 | 2024-09-16 21:23:02 | 
| 合計ジャッジ時間 | 26,835 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge6 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 28 | 
ソースコード
import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())
W,H,X = MI()
if H % 3 == 2:
    a = 2
else:
    a = 1
if W % 3 == 2:
    b = 2
else:
    b = 1
if 9*a*b < X:
    print(-1)
    exit()
A = []
for i in range(a*b):
    for j in range(10):
        if 0 <= X-j <= 9*(a*b-1-i):
            A.append(j)
            X -= j
            break
if H % 3 == 0:
    if W % 3 == 0:
        ans0 = '0'*W
        ans1 = ('0'+str(A[0])+'0')*(W//3)
        ans2 = '0'*W
    elif W % 3 == 1:
        ans0 = '0'*W
        ans1 = (str(A[0])+'00')*(W//3)+str(A[0])
        ans2 = '0'*W
    else:
        ans0 = '0'*W
        ans1 = (str(A[0])+str(A[1])+'0')*(W//3)+str(A[0])+str(A[1])
        ans2 = '0'*W
elif H % 3 == 1:
    if W % 3 == 0:
        ans0 = ('0'+str(A[0])+'0')*(W//3)
        ans1 = '0'*W
        ans2 = '0'*W
    elif W % 3 == 1:
        ans0 = (str(A[0])+'00')*(W//3)+str(A[0])
        ans1 = '0'*W
        ans2 = '0'*W
    else:
        ans0 = (str(A[0])+str(A[1])+'0')*(W//3)+str(A[0])+str(A[1])
        ans1 = '0'*W
        ans2 = '0'*W
else:
    if W % 3 == 0:
        ans0 = ('0'+str(A[0])+'0')*(W//3)
        ans1 = ('0'+str(A[1])+'0')*(W//3)
        ans2 = '0'*W
    elif W % 3 == 1:
        ans0 = (str(A[0])+'00')*(W//3)+str(A[0])
        ans1 = (str(A[1])+'00')*(W//3)+str(A[1])
        ans2 = '0'*W
    else:
        ans0 = (str(A[0])+str(A[1])+'0')*(W//3)+str(A[0])+str(A[1])
        ans1 = (str(A[2])+str(A[3])+'0')*(W//3)+str(A[2])+str(A[3])
        ans2 = '0'*W
for i in range(H):
    if i % 3 == 0:
        print(ans0)
    elif i % 3 == 1:
        print(ans1)
    else:
        print(ans2)
            
            
            
        