結果
問題 | No.2779 Don't make Pair |
ユーザー |
👑 |
提出日時 | 2024-09-07 14:16:55 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 624 bytes |
コンパイル時間 | 458 ms |
コンパイル使用メモリ | 7,072 KB |
実行使用メモリ | 13,980 KB |
最終ジャッジ日時 | 2024-09-07 14:16:59 |
合計ジャッジ時間 | 4,085 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 24 |
ソースコード
n = io.read("*n") a = {} for i = 1, n do a[i] = io.read("*n") end l = {true} t = {} t[a[1]] = true for i = 2, n do ai = a[i] if t[ai] then for j = i, n do l[j] = false end break else l[i] = true t[ai] = true end end r = {} for i = 1, n do r[i] = false end r[n] = true t = {} t[a[n]] = true for i = n - 1, 1, -1 do ai = a[i] if t[ai] then for j = i, 1, -1 do r[j] = false end break else r[i] = true t[ai] = true end end ans = {} for i = 1, n - 1 do if l[i] and r[i + 1] then table.insert(ans, i) end end print(#ans) print(table.concat(ans, " "))