結果

問題 No.2779 Don't make Pair
ユーザー 👑 KA37RI
提出日時 2024-06-07 22:13:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 422 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 117,248 KB
最終ジャッジ日時 2024-12-26 08:19:57
合計ジャッジ時間 5,465 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 2
other AC * 13 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

n = int(input())
a = [int(x) for x in input().split()]

cnt = Counter(a)

if any(cnt[x] >= 3 for x in a):
	print("0\n")
	exit()
	
left = {}
right = {}

for i in range(n):
	right[a[i]] = i
	
for i in range(n - 1, -1, -1):
	left[a[i]] = i

p = 0
q = n

for x in a:
	if left[x] == right[x]:
		continue
	p = max(left[x], p)
	q = min(right[x], q)
	
r = range(p + 1, q)

print(len(r))
print(*r)
0