結果

問題 No.2256 Step by Step
ユーザー 👑 rin204rin204
提出日時 2024-04-29 16:54:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 2,750 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 64,896 KB
最終ジャッジ日時 2024-04-29 16:54:42
合計ジャッジ時間 3,373 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,352 KB
testcase_01 AC 37 ms
52,480 KB
testcase_02 AC 48 ms
64,384 KB
testcase_03 AC 49 ms
64,768 KB
testcase_04 AC 50 ms
64,512 KB
testcase_05 AC 49 ms
64,896 KB
testcase_06 AC 38 ms
52,352 KB
testcase_07 AC 36 ms
53,120 KB
testcase_08 AC 54 ms
52,480 KB
testcase_09 AC 37 ms
53,248 KB
testcase_10 AC 37 ms
53,120 KB
testcase_11 AC 38 ms
52,992 KB
testcase_12 AC 46 ms
61,568 KB
testcase_13 AC 48 ms
63,380 KB
testcase_14 AC 38 ms
53,504 KB
testcase_15 AC 44 ms
61,076 KB
testcase_16 AC 38 ms
52,736 KB
testcase_17 AC 46 ms
63,104 KB
testcase_18 AC 50 ms
64,128 KB
testcase_19 AC 48 ms
63,616 KB
testcase_20 AC 46 ms
60,928 KB
testcase_21 AC 46 ms
60,928 KB
testcase_22 AC 47 ms
63,232 KB
testcase_23 AC 41 ms
58,624 KB
testcase_24 AC 45 ms
61,696 KB
testcase_25 AC 47 ms
61,184 KB
testcase_26 AC 51 ms
64,384 KB
testcase_27 AC 45 ms
61,824 KB
testcase_28 AC 35 ms
52,864 KB
testcase_29 AC 42 ms
58,496 KB
testcase_30 AC 47 ms
62,592 KB
testcase_31 AC 38 ms
53,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
if n == 1:
    ans = [
        ["1"],
        ["1"],
        ["0"],
        ["0"],
        ["0"],
        ["1"],
    ]
elif n == 2:
    print(-1)
    exit()
else:
    if n % 2 == 1:
        ans = [
            ["0", "1", "2"],
            ["3", "4", "5"],
            ["3", "4", "5"],
            ["2", "2", "5"],
            ["1", "4", "1"],
            ["3", "0", "0"],
        ]

    else:
        ans = [
            ["9", "1", "1", "2"],
            ["7", "9", "9", "5"],
            ["3", "1", "1", "5"],
            ["1", "2", "2", "5"],
            ["3", "0", "0", "1"],
            ["3", "7", "7", "0"],
        ]

    add1 = [
        ["8", "0", "6"],
        ["0", "4", "2"],
        ["2", "4", "2"],
        ["6", "6", "2"],
        ["1", "8", "8"],
        ["0", "4", "0"],
    ]

    add2 = [
        ["9", "1", "7"],
        ["1", "5", "3"],
        ["6", "5", "3"],
        ["7", "7", "3"],
        ["8", "9", "9"],
        ["0", "5", "1"],
    ]

    add3 = [
        ["8", "0", "6"],
        ["0", "4", "2"],
        ["7", "4", "2"],
        ["6", "6", "2"],
        ["9", "8", "8"],
        ["1", "4", "0"],
    ]

    while len(ans[0]) < n:
        for i in range(6):
            ans[i].pop()
            ans[i].extend(add1[i])
        add1, add2 = add2, add1
        if add3 is not None:
            add2 = add3[:]
            add3 = None

for row in ans:
    print(*row, sep="")

exit()


def upd(S):
    n = len(S)
    m = len(S[0])
    c = 0
    delete = [[False] * m for _ in range(n)]
    for i in range(n):
        for j in range(m):
            if (
                i >= 2
                and S[i - 2][j] == S[i - 1][j] == S[i][j] != "?"
                and S[i][j] != "_"
            ):
                delete[i][j] = True
                delete[i - 1][j] = True
                delete[i - 2][j] = True
                c += 1
            if (
                j >= 2
                and S[i][j - 2] == S[i][j - 1] == S[i][j] != "?"
                and S[i][j] != "_"
            ):
                delete[i][j] = True
                delete[i][j - 1] = True
                delete[i][j - 2] = True
                c += 1
    if c != 1:
        return False

    for j in range(m):
        t = n - 1
        for i in range(n - 1, -1, -1):
            if delete[i][j]:
                continue
            S[t][j] = S[i][j]
            t -= 1
        for i in range(t, -1, -1):
            S[i][j] = "?"

    return True


def ok(S):
    n = len(S[0]) * 2
    while upd(S) and n > 0:
        pass
        n -= 1

        for row in S:
            print(*row, sep="")
        print()

    for row in S:
        if any(s != "?" for s in row):
            return False
    return True


print()
assert ok(ans)
0