結果
問題 | No.2779 Don't make Pair |
ユーザー |
|
提出日時 | 2024-06-07 22:30:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 187 ms / 2,000 ms |
コード長 | 387 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 107,220 KB |
最終ジャッジ日時 | 2024-12-26 08:39:49 |
合計ジャッジ時間 | 4,597 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 24 |
ソースコード
from collections import defaultdict N=int(input()) A=list(map(int,input().split())) d1=defaultdict(int) d2=defaultdict(int) for a in A:d1[a]+=1 cnt1=0 cnt2=0 for _,v in d1.items(): if v>1:cnt1+=1 ans=[] for i in range(N-1): a=A[i] d1[a]-=1 d2[a]+=1 if d1[a]==1:cnt1-=1 if d2[a]>1:cnt2+=1 if cnt1==0 and cnt2==0:ans.append(i+1) print(len(ans)) print(*ans)