結果

問題 No.2779 Don't make Pair
コンテスト
ユーザー manoto43
提出日時 2024-06-07 22:44:06
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 99 ms / 2,000 ms
+ 70µs
コード長 608 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 144 ms
コンパイル使用メモリ 80,796 KB
実行使用メモリ 129,292 KB
最終ジャッジ日時 2026-10-08 06:08:17
合計ジャッジ時間 4,163 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import Counter,defaultdict

def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    l,r = set(),set()
    d_l,d_r = defaultdict(int),Counter(A)

    for k in d_r.keys():
        if d_r[k] > 1:
            r.add(k)
    
    ans = []

    for i,a in enumerate(A[:-1]):
        d_l[a] += 1
        if d_l[a] > 1:
            l.add(a)
        
        d_r[a] -= 1
        if d_r[a] <= 1 and a in r:
            r.remove(a)
        
        if not(l or r):
            ans.append(i+1)
    
    print(len(ans))
    print(*ans)







if __name__ == "__main__":
    main()
0