結果
| 問題 |
No.2672 Subset Xor Sum
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2024-11-10 13:53:57 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,218 bytes |
| コンパイル時間 | 372 ms |
| コンパイル使用メモリ | 7,076 KB |
| 実行使用メモリ | 7,040 KB |
| 最終ジャッジ日時 | 2024-11-10 13:54:01 |
| 合計ジャッジ時間 | 3,780 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 43 WA * 7 RE * 16 |
ソースコード
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 = 5000
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] + 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")