結果

問題 No.1820 NandShift
ユーザー 👑 tamatotamato
提出日時 2022-01-21 23:36:11
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,316 bytes
コンパイル時間 590 ms
コンパイル使用メモリ 87,620 KB
実行使用メモリ 77,844 KB
最終ジャッジ日時 2023-08-17 08:23:54
合計ジャッジ時間 4,390 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
72,804 KB
testcase_01 AC 70 ms
72,228 KB
testcase_02 AC 71 ms
72,672 KB
testcase_03 AC 71 ms
72,552 KB
testcase_04 AC 78 ms
72,516 KB
testcase_05 AC 71 ms
72,528 KB
testcase_06 AC 71 ms
72,664 KB
testcase_07 AC 80 ms
77,568 KB
testcase_08 AC 71 ms
72,364 KB
testcase_09 AC 80 ms
76,820 KB
testcase_10 AC 85 ms
77,844 KB
testcase_11 AC 71 ms
72,596 KB
testcase_12 AC 71 ms
72,804 KB
testcase_13 AC 76 ms
76,836 KB
testcase_14 AC 70 ms
72,620 KB
testcase_15 AC 77 ms
77,396 KB
testcase_16 AC 81 ms
77,572 KB
testcase_17 AC 70 ms
72,688 KB
testcase_18 AC 79 ms
77,508 KB
testcase_19 AC 80 ms
77,460 KB
testcase_20 AC 70 ms
72,404 KB
testcase_21 AC 69 ms
72,368 KB
testcase_22 AC 71 ms
72,272 KB
testcase_23 AC 70 ms
72,332 KB
testcase_24 AC 79 ms
77,180 KB
testcase_25 AC 80 ms
77,444 KB
testcase_26 AC 72 ms
72,564 KB
testcase_27 AC 78 ms
77,248 KB
testcase_28 AC 81 ms
77,420 KB
testcase_29 AC 69 ms
72,536 KB
testcase_30 AC 80 ms
77,136 KB
testcase_31 AC 83 ms
76,988 KB
権限があれば一括ダウンロードができます

ソースコード

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 == "1":
                u.append("0")
            else:
                u.append("1")
        return "".join(u)

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

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

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

    for k in range(M):
        ans.append((1, NN + 4, NN + 4))
        Y[NN+4] = f1(Y[NN+4])
        if X[k] == "1":
            ans.append((2, L, NN+4, NN+1))
            Y[L] = f2(Y[NN+4], Y[NN+1])
            ans.append((2, NN+4, L, NN+2))
            Y[NN+4] = f2(Y[L], Y[NN+2])
    ans.append((2, L+1, NN+4, NN+1))
    Y[L+1] = f2(Y[NN+4], Y[NN+1])
    ans.append((2, 0, L+1, NN+1))
    Y[0] = f2(Y[L+1], Y[NN+1])

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

    assert X == Y[0]


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