結果
問題 | No.1871 divisXor |
ユーザー | chineristAC |
提出日時 | 2022-03-11 21:36:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 2,666 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 82,424 KB |
実行使用メモリ | 58,224 KB |
最終ジャッジ日時 | 2024-09-22 12:53:57 |
合計ジャッジ時間 | 4,127 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
57,244 KB |
testcase_01 | AC | 47 ms
58,164 KB |
testcase_02 | AC | 46 ms
58,224 KB |
testcase_03 | AC | 45 ms
58,040 KB |
testcase_04 | AC | 45 ms
57,032 KB |
testcase_05 | AC | 46 ms
57,164 KB |
testcase_06 | AC | 45 ms
57,216 KB |
testcase_07 | AC | 44 ms
57,832 KB |
testcase_08 | AC | 45 ms
56,936 KB |
testcase_09 | AC | 45 ms
57,460 KB |
testcase_10 | AC | 48 ms
57,016 KB |
testcase_11 | AC | 48 ms
56,532 KB |
testcase_12 | AC | 46 ms
57,032 KB |
testcase_13 | AC | 46 ms
57,420 KB |
testcase_14 | AC | 45 ms
56,628 KB |
testcase_15 | AC | 46 ms
56,712 KB |
testcase_16 | AC | 46 ms
57,536 KB |
testcase_17 | AC | 46 ms
56,996 KB |
testcase_18 | AC | 45 ms
57,456 KB |
testcase_19 | AC | 44 ms
56,608 KB |
testcase_20 | AC | 45 ms
57,244 KB |
testcase_21 | AC | 46 ms
57,152 KB |
testcase_22 | AC | 45 ms
57,036 KB |
testcase_23 | AC | 46 ms
57,484 KB |
testcase_24 | AC | 45 ms
56,332 KB |
testcase_25 | AC | 45 ms
57,092 KB |
testcase_26 | AC | 45 ms
58,072 KB |
testcase_27 | AC | 46 ms
57,020 KB |
testcase_28 | AC | 47 ms
56,904 KB |
testcase_29 | AC | 48 ms
57,288 KB |
testcase_30 | AC | 46 ms
57,148 KB |
ソースコード
class SegmentTree: def __init__(self, init_val, segfunc, ide_ele): n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num self.size = n for i in range(n): self.tree[self.num + i] = init_val[i] for i in range(self.num - 1, 0, -1): self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1]) def update(self, k, x): k += self.num self.tree[k] = x while k > 1: k >>= 1 self.tree[k] = self.segfunc(self.tree[2*k], self.tree[2*k+1]) def query(self, l, r): if r==self.size: r = self.num res = self.ide_ele l += self.num r += self.num right = [] while l < r: if l & 1: res = self.segfunc(res, self.tree[l]) l += 1 if r & 1: right.append(self.tree[r-1]) l >>= 1 r >>= 1 for e in right[::-1]: res = self.segfunc(res,e) return res def bisect(self,l,r,x): if r==self.size: r = self.num l += self.num r += self.num segment = [] segment_r = [] while l<r: if l&1: segment.append(l) l += 1 if r&1: segment_r.append(r-1) l >>= 1 r >>= 1 segment += segment_r[::-1] tmp = self.ide_ele for pos in segment: check = self.segfunc(tmp,self.tree[pos]) if check > x: break else: tmp = check else: return -1 while pos < self.num: check = self.segfunc(tmp,self.tree[2*pos]) if check > x: pos = 2 * pos else: tmp = check pos = 2 * pos + 1 return pos - self.num import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N = int(input()) if N==0: exit(print(-1)) cnt = [0 for i in range(40)] for k in range(40): if N>>k & 1: if k==0: cnt[0] ^= 1 else: cnt[k] ^= 1 cnt[k-1] ^= 1 res = [pow(2,i) for i in range(40) if cnt[i]] if sum(res) < 2 * N: print(len(res)) print(*res) else: print(-1)