結果
問題 |
No.2563 色ごとのグループ
|
ユーザー |
|
提出日時 | 2023-12-02 15:00:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 782 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 114,984 KB |
最終ジャッジ日時 | 2024-09-26 17:52:55 |
合計ジャッジ時間 | 6,514 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 WA * 5 |
ソースコード
import sys,math #if len(sys.argv)==2:sys.stdin=open(sys.argv[1]) from collections import defaultdict,deque from itertools import combinations,permutations,accumulate,product from bisect import bisect,bisect_left,bisect_right from heapq import heappop,heappush,heapify #from sortedcontainers import SortedList,SortedSet def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def ms(): return map(int, input().split()) def li(): return list(map(int,input().split())) #//////////////////////////////////// N,M = ms() C = li() ans = 0 gro = defaultdict(list) for i in range(N): gro[C[i]].append(i+1) cnt = defaultdict(int) for _ in range(M): u,v = ms() if C[u-1]==C[v-1]: cnt[C[u-1]] += 1 for c in gro.keys(): ans += len(gro[c])-cnt[c]-1 print(ans)