結果

問題 No.1589 Bit Vector
ユーザー shotoyooshotoyoo
提出日時 2021-09-26 17:46:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 1,166 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 78,704 KB
最終ジャッジ日時 2023-09-19 02:56:21
合計ジャッジ時間 6,635 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
72,216 KB
testcase_01 AC 95 ms
72,168 KB
testcase_02 AC 95 ms
72,084 KB
testcase_03 AC 95 ms
72,072 KB
testcase_04 AC 94 ms
72,232 KB
testcase_05 AC 95 ms
72,248 KB
testcase_06 AC 92 ms
72,208 KB
testcase_07 AC 96 ms
72,480 KB
testcase_08 AC 96 ms
72,308 KB
testcase_09 AC 95 ms
72,288 KB
testcase_10 AC 97 ms
72,492 KB
testcase_11 AC 98 ms
72,228 KB
testcase_12 AC 99 ms
72,252 KB
testcase_13 AC 95 ms
72,060 KB
testcase_14 AC 94 ms
72,212 KB
testcase_15 AC 92 ms
72,496 KB
testcase_16 AC 93 ms
72,176 KB
testcase_17 AC 93 ms
72,272 KB
testcase_18 AC 94 ms
72,232 KB
testcase_19 AC 97 ms
72,264 KB
testcase_20 AC 118 ms
78,448 KB
testcase_21 AC 120 ms
78,536 KB
testcase_22 AC 116 ms
78,556 KB
testcase_23 AC 116 ms
78,372 KB
testcase_24 AC 118 ms
78,680 KB
testcase_25 AC 121 ms
78,444 KB
testcase_26 AC 119 ms
78,536 KB
testcase_27 AC 119 ms
78,704 KB
testcase_28 AC 116 ms
78,348 KB
testcase_29 AC 119 ms
78,680 KB
testcase_30 AC 119 ms
78,552 KB
testcase_31 AC 116 ms
78,576 KB
testcase_32 AC 117 ms
78,348 KB
testcase_33 AC 120 ms
78,560 KB
testcase_34 AC 120 ms
78,480 KB
testcase_35 AC 94 ms
72,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n,k = list(map(int, input().split()))
t = int(input())
for _ in range(t):
    _ = list(map(int, input().split()))
def main(n,K):
    import random
    _a = [random.randint(0,1) for _ in range(n+1)]
    _a0 = _a[:]
    s = sum(_a[:n])
    ans = []
    def UPD(i, v):
        ans.append(("UPD", i, v))
        _a[i] = v
    def AND(i, j, k):
        ans.append(("AND", k, i, j))
        _a[k] = _a[i] and _a[j]
    def XOR(i, j, k):
        ans.append(("XOR", k, i, j))
        _a[k] = _a[i]^_a[j]
    def swap(i,j):
        UPD(n,0)
        XOR(i,n,n)
        AND(i,j,i)
        XOR(j,n,n)
        XOR(i,n,j)
    for i in range(1,n):
        for j in range(i)[::-1]:
            swap(j,j+1)
    UPD(n,0)
    XOR(n-K,n,n)
    s2 = sum(_a[:n])
    assert s==s2 and _a[-1]==(s>=K)
    assert all((_a[i]==0 for i in range(n-s))), (_a0, _a[:n])
    assert len(ans)<=10000
    return ans
ans = main(n,k)
print(len(ans))
write("\n".join([" ".join(map(str, item)) for item in ans]))
0