結果

問題 No.2563 色ごとのグループ
ユーザー かもめのうで
提出日時 2023-12-02 16:03:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 511 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 146,200 KB
最終ジャッジ日時 2024-09-26 19:45:06
合計ジャッジ時間 7,937 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
c = list(map(int, input().split()))

cnt = [set() for _ in range(n)]
for i in range(n):
    cnt[c[i]-1].add(i)

s = set()
edge = [0]*n
for _ in range(m):
    v, u = map(int, input().split())
    v -= 1
    u -= 1
    if c[v] == c[u]:
        if (v, u) not in s and (u, v) not in s:
            edge[c[v]-1] += 1
            s.add((v, u))
            s.add((u, v))

ans = 0
for e, t in zip(edge, cnt):
    if len(t) == 0:
        continue
    ans += max(len(t)-1-e, 0)
print(ans)
0