結果

問題 No.2779 Don't make Pair
ユーザー ntuda
提出日時 2024-06-08 09:55:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 595 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 102,420 KB
最終ジャッジ日時 2024-12-27 12:21:49
合計ジャッジ時間 4,780 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
dic = defaultdict(list)
for i, a in enumerate(A):
    dic[a].append(i)
left = 1
right = N - 1
for v in dic.values():
    if len(v) > 2:
        print(0)
        print()
        exit()
    elif len(v) == 2:
        left = max(left, v[0] + 1)
        right = min(right, v[1])
if left <= right:
    print(right - left + 1)
    print(*range(left, right + 1))
else:
    print(0)
    print()
0