結果

問題 No.862 XORでX
ユーザー convexineqconvexineq
提出日時 2021-04-04 12:56:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 512 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 80,744 KB
最終ジャッジ日時 2023-08-27 12:56:17
合計ジャッジ時間 6,918 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
77,492 KB
testcase_01 AC 90 ms
77,320 KB
testcase_02 AC 90 ms
77,524 KB
testcase_03 AC 93 ms
77,252 KB
testcase_04 AC 89 ms
77,300 KB
testcase_05 AC 91 ms
77,480 KB
testcase_06 AC 90 ms
77,364 KB
testcase_07 AC 90 ms
77,464 KB
testcase_08 AC 138 ms
79,732 KB
testcase_09 AC 103 ms
79,764 KB
testcase_10 AC 102 ms
79,736 KB
testcase_11 AC 102 ms
79,668 KB
testcase_12 AC 89 ms
77,316 KB
testcase_13 AC 89 ms
77,568 KB
testcase_14 AC 89 ms
77,704 KB
testcase_15 AC 89 ms
77,344 KB
testcase_16 AC 110 ms
79,772 KB
testcase_17 AC 106 ms
79,496 KB
testcase_18 AC 106 ms
79,772 KB
testcase_19 AC 111 ms
79,752 KB
testcase_20 AC 153 ms
80,344 KB
testcase_21 AC 164 ms
80,188 KB
testcase_22 AC 166 ms
80,332 KB
testcase_23 AC 172 ms
80,196 KB
testcase_24 AC 112 ms
79,628 KB
testcase_25 AC 114 ms
79,768 KB
testcase_26 AC 128 ms
80,000 KB
testcase_27 AC 166 ms
80,520 KB
testcase_28 AC 178 ms
80,388 KB
testcase_29 AC 135 ms
80,404 KB
testcase_30 AC 166 ms
80,744 KB
testcase_31 AC 177 ms
80,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,x = map(int, input().split())
M = 10**5+6
use = list(range(1,n+1))
use_lst = [0]*M
v = 0
for i in range(1,n+1):
    v ^= i
    use_lst[i] = 1
free = list(range(n+1,M))
nn = M-n-1

cnt = 0
from random import randrange
while v != x:
    idx = randrange(0,n)
    y = use[idx]
    v ^= y
    if 0 < v^x < M and use_lst[v^x]==0:
        use[idx] = v^x
        break
    jdx = randrange(0,nn)
    w = free[jdx]
    v ^= w
    use_lst[y] = 0
    use_lst[w] = 1
    use[idx],free[jdx] = w,y

for i in use:
    print(i)
0