結果

問題 No.1820 NandShift
ユーザー 👑 tamatotamato
提出日時 2022-01-21 23:01:53
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,421 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 87,688 KB
実行使用メモリ 77,748 KB
最終ジャッジ日時 2023-08-17 07:30:34
合計ジャッジ時間 4,609 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
72,428 KB
testcase_01 AC 70 ms
72,652 KB
testcase_02 AC 71 ms
72,568 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 71 ms
72,684 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 79 ms
77,528 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 71 ms
72,592 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    def f1(s):
        return s[1:] + "0"

    def f2(s, t):
        u = []
        for ss, tt in zip(s, t):
            if ss == tt == "0":
                u.append("1")
            else:
                u.append("0")
        return "".join(u)

    N, M = map(int, input().split())
    X = input().rstrip('\n')
    for _ in range(N):
        s = input().rstrip('\n')

    L = 10 ** 5
    Y = ["0" * M] * (L + 10)

    ans = []
    # make 1
    ans.append((2, N+1, 0, 0))
    Y[N+1] = f2(Y[0], Y[0])
    ans.append((1, N+2, N+1))
    Y[N+2] = f1(Y[N+1])
    ans.append((2, N+3, N+2, 0))
    Y[N+3] = f2(Y[N+2], Y[0])
    ans.append((2, N+4, N+2, 0))
    Y[N+4] = f2(Y[N+2], Y[0])

    for i in range(M):
        if X[i] == "1":
            K = M - i
            break
    for k in range(K - 1):
        ans.append((1, N + 4, N + 4))
        Y[N+4] = f1(Y[N+4])
        if X[M - K + k + 1] == "1":
            ans.append((2, L, N+4, N+3))
            Y[L] = f2(Y[N+4], Y[N+3])
            ans.append((2, N+4, L, 0))
            Y[N+4] = f2(Y[L], Y[0])
    ans.append((2, L+1, N+4, 0))
    Y[L+1] = f2(Y[N+4], Y[0])
    ans.append((2, 0, L+1, L+2))
    Y[0] = f2(Y[L+1], Y[L+2])

    assert len(ans) <= 1000
    print(len(ans))
    for line in ans:
        print(*line)

    assert X == Y[0]


if __name__ == '__main__':
    main()
0