結果
問題 | No.2672 Subset Xor Sum |
ユーザー |
👑 |
提出日時 | 2024-11-10 13:57:25 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,236 bytes |
コンパイル時間 | 251 ms |
コンパイル使用メモリ | 7,200 KB |
実行使用メモリ | 6,912 KB |
最終ジャッジ日時 | 2024-11-10 13:57:29 |
合計ジャッジ時間 | 3,412 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 63 WA * 3 |
ソースコード
local bxor = bit.bxor local n = io.read("*n") local a = {} local v = 0 for i = 1, n do a[i] = io.read("*n") v = bxor(v, a[i]) end if 0 < v then print("No") os.exit() end for i = 1, n do if a[i] == 0 then print("Yes") os.exit() end end local len = {} local tasks = {} local lim = 8192 for i = 1, lim do len[i] = 0 end local map = {} local edge = {} for i = 1, n do if map[a[i]] then print("Yes") os.exit() end map[a[i]] = true len[a[i]] = 1 table.insert(tasks, a[i]) table.insert(edge, a[i]) end local done = 0 while done < #tasks do done = done + 1 local src = tasks[done] -- print(src) for i = 1, #edge do local e = edge[i] if src ~= e then local dst = bxor(src, e) if dst == 0 then if len[src] + 1 < n then print("Yes") os.exit() end else if len[dst] == 1 and len[src] ~= 2 and len[src] + len[dst] + 1 < n then -- print(src, dst, len[src], len[dst]) print("Yes") os.exit() end if len[dst] == 0 or len[src] + 1 < len[dst] then len[dst] = len[src] + 1 table.insert(tasks, dst) end end end end end -- for i = 1, lim do -- print(i, len[i]) -- end print("No")