結果

問題 No.2563 色ごとのグループ
コンテスト
ユーザー raspberry1729
提出日時 2023-12-02 16:00:36
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ac-library)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 430 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 278 ms
コンパイル使用メモリ 21,468 KB
実行使用メモリ 16,684 KB
最終ジャッジ日時 2026-09-05 01:34:20
合計ジャッジ時間 7,778 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

a,b=map(int,input().split())
c=list(map(int,input().split()))
ans=0
zoff=[]
strawberry=[[] for i in range(a)]
very=sorted(set(c))
for _ in very:
	zoff.append(c.count(_))
for i in range(a-1):
	for j in range(i+1,a):
		if c[i]==c[j]:
			strawberry[i].append(j)
			strawberry[j].append(i)
ans=sum(zoff)-len(zoff)
for i in range(b):
	yaakiyu,kafeore=map(int,input().split())
	if kafeore-1 in strawberry[yaakiyu-1]:
		ans-=1
print(ans)
0