結果

問題 No.1589 Bit Vector
ユーザー trineutrontrineutron
提出日時 2021-07-09 00:08:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,127 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-09-14 05:49:30
合計ジャッジ時間 6,407 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,216 KB
testcase_01 AC 18 ms
8,260 KB
testcase_02 AC 17 ms
8,356 KB
testcase_03 AC 18 ms
8,196 KB
testcase_04 WA -
testcase_05 AC 17 ms
8,164 KB
testcase_06 AC 17 ms
7,744 KB
testcase_07 WA -
testcase_08 AC 17 ms
8,164 KB
testcase_09 AC 17 ms
8,168 KB
testcase_10 AC 16 ms
8,212 KB
testcase_11 WA -
testcase_12 AC 17 ms
8,216 KB
testcase_13 WA -
testcase_14 AC 16 ms
8,192 KB
testcase_15 AC 16 ms
8,308 KB
testcase_16 WA -
testcase_17 AC 17 ms
8,248 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 23 ms
8,428 KB
testcase_21 AC 23 ms
8,504 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 23 ms
8,508 KB
testcase_28 AC 22 ms
8,504 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 16 ms
8,220 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:
        for j in range(i, n - 1):
            ans.append("UPD " + str(n - 1) + " 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))

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