結果
問題 |
No.2779 Don't make Pair
|
ユーザー |
|
提出日時 | 2024-07-10 17:35:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 155 ms / 2,000 ms |
コード長 | 750 bytes |
コンパイル時間 | 469 ms |
コンパイル使用メモリ | 82,128 KB |
実行使用メモリ | 111,740 KB |
最終ジャッジ日時 | 2024-07-10 17:35:39 |
合計ジャッジ時間 | 5,373 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 24 |
ソースコード
from collections import Counter def main(): N = int(input()) A = list(map(int, input().split())) left_ctr = Counter() right_ctr = Counter(A) left_dup_flag = False right_dup_nums = set() for n, v in right_ctr.items(): if v > 1: right_dup_nums.add(n) ans = [] for idx in range(N - 1): move_n = A[idx] right_ctr[move_n] -= 1 if right_ctr[move_n] == 1: right_dup_nums.remove(move_n) if left_ctr[move_n] > 0: left_dup_flag = True left_ctr[move_n] += 1 if not left_dup_flag and not right_dup_nums: ans.append(idx) print(len(ans)) print(*map(lambda n: n + 1, ans)) if __name__ == "__main__": main()