結果

問題 No.1589 Bit Vector
ユーザー trineutrontrineutron
提出日時 2021-07-09 00:58:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,393 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 8,868 KB
最終ジャッジ日時 2023-09-14 06:14:04
合計ジャッジ時間 3,103 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,996 KB
testcase_01 AC 17 ms
8,344 KB
testcase_02 AC 18 ms
8,036 KB
testcase_03 AC 16 ms
8,116 KB
testcase_04 AC 16 ms
8,308 KB
testcase_05 AC 16 ms
8,072 KB
testcase_06 AC 16 ms
8,048 KB
testcase_07 AC 16 ms
8,056 KB
testcase_08 AC 16 ms
8,300 KB
testcase_09 AC 16 ms
8,064 KB
testcase_10 AC 17 ms
8,052 KB
testcase_11 AC 16 ms
8,000 KB
testcase_12 AC 16 ms
8,056 KB
testcase_13 AC 16 ms
8,352 KB
testcase_14 AC 16 ms
8,088 KB
testcase_15 AC 16 ms
8,188 KB
testcase_16 AC 16 ms
8,168 KB
testcase_17 AC 16 ms
8,072 KB
testcase_18 AC 16 ms
8,096 KB
testcase_19 AC 17 ms
8,360 KB
testcase_20 AC 23 ms
8,868 KB
testcase_21 AC 23 ms
8,800 KB
testcase_22 AC 23 ms
8,856 KB
testcase_23 AC 24 ms
8,772 KB
testcase_24 AC 23 ms
8,716 KB
testcase_25 AC 24 ms
8,736 KB
testcase_26 AC 17 ms
8,380 KB
testcase_27 AC 23 ms
8,692 KB
testcase_28 AC 23 ms
8,848 KB
testcase_29 AC 23 ms
8,700 KB
testcase_30 AC 23 ms
8,756 KB
testcase_31 AC 24 ms
8,712 KB
testcase_32 AC 24 ms
8,724 KB
testcase_33 AC 24 ms
8,808 KB
testcase_34 AC 16 ms
8,284 KB
testcase_35 AC 16 ms
8,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if n == k:
    ans = []
    ans.append("UPD " + str(n) + " 1")
    for i in range(n):
        ans.append("AND " + str(n) + " " + str(i) + " " + str(n))
    print(len(ans))
    for s in ans:
        print(s)
    exit()

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)
0