結果

問題 No.1587 012 Matrix
ユーザー lam6er
提出日時 2025-03-31 18:00:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 82,108 KB
実行使用メモリ 73,900 KB
最終ジャッジ日時 2025-03-31 18:02:13
合計ジャッジ時間 5,335 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

if n == 2:
    print("01")
    print("22")
else:
    # General solution for n >= 4 and even
    matrix = []
    half = n // 2
    # First half of rows: 0 followed by 1s, ensuring row sum increases
    for i in range(half):
        row = [0] * (half - i - 1) + [1] * (half + i + 1)
        matrix.append(row[:n])
    # Remaining rows filled with 2
    for _ in range(half):
        matrix.append([2] * n)
    # Output the matrix
    for row in matrix:
        print(''.join(map(str, row)))
0