結果

問題 No.1589 Bit Vector
ユーザー trineutrontrineutron
提出日時 2021-07-09 00:48:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,201 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,772 KB
実行使用メモリ 8,620 KB
最終ジャッジ日時 2023-09-14 06:13:53
合計ジャッジ時間 3,812 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,004 KB
testcase_01 AC 17 ms
8,104 KB
testcase_02 AC 17 ms
8,112 KB
testcase_03 AC 17 ms
8,056 KB
testcase_04 WA -
testcase_05 AC 16 ms
8,080 KB
testcase_06 AC 17 ms
8,068 KB
testcase_07 AC 17 ms
8,092 KB
testcase_08 AC 16 ms
8,124 KB
testcase_09 AC 17 ms
8,000 KB
testcase_10 AC 16 ms
8,052 KB
testcase_11 AC 17 ms
8,084 KB
testcase_12 AC 16 ms
8,040 KB
testcase_13 AC 16 ms
8,048 KB
testcase_14 AC 16 ms
8,072 KB
testcase_15 AC 16 ms
8,104 KB
testcase_16 AC 17 ms
8,032 KB
testcase_17 AC 17 ms
8,124 KB
testcase_18 AC 16 ms
8,072 KB
testcase_19 AC 16 ms
8,172 KB
testcase_20 AC 23 ms
8,524 KB
testcase_21 AC 23 ms
8,584 KB
testcase_22 AC 24 ms
8,620 KB
testcase_23 AC 24 ms
8,524 KB
testcase_24 AC 23 ms
8,428 KB
testcase_25 AC 24 ms
8,564 KB
testcase_26 AC 24 ms
8,388 KB
testcase_27 AC 22 ms
8,504 KB
testcase_28 AC 23 ms
8,508 KB
testcase_29 AC 23 ms
8,512 KB
testcase_30 AC 24 ms
8,516 KB
testcase_31 AC 22 ms
8,384 KB
testcase_32 AC 23 ms
8,504 KB
testcase_33 AC 23 ms
8,608 KB
testcase_34 AC 23 ms
8,460 KB
testcase_35 AC 16 ms
8,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())

r = 1
d = 0
while r < k:
    r *= 2
    d += 1
r -= k

ans = []
for i in range(1, n):
    for j in range(i):
        ans.append("AND " + str(n) + " " + str(j) + " " + str(i))
        ans.append("XOR " + str(j) + " " + str(j) + " " + str(i))
        ans.append("UPD " + str(i) + " 0")
        ans.append("XOR " + str(i) + " " + str(i) + " " + str(n))

for i in range(n):
    if (r >> i) & 1:
        ans.append("UPD " + str(n - 1) + " 1")
        for j in range(i, n - 1):
            ans.append("AND " + str(n) + " " + str(j) + " " + str(n - 1))
            ans.append("XOR " + str(j) + " " + str(j) + " " + str(n - 1))
            ans.append("UPD " + str(n - 1) + " 0")
            ans.append("XOR " + str(n - 1) + " " + str(n - 1) + " " + str(n))

if r:
    ans.append("UPD " + str(n - 1) + " 0")
ans.append("UPD " + str(n) + " 1")
for i in range(d, n):
    ans.append("XOR " + str(i) + " " + str(i) + " " + str(n))
for i in range(d, n):
    ans.append("AND " + str(n) + " " + str(i) + " " + str(n))

ans.append("UPD " + str(0) + " 1")
ans.append("XOR " + str(n) + " " + str(0) + " " + str(n))

print(len(ans))
for s in ans:
    print(s)

assert(len(ans) <= 10000)
0