結果

問題 No.2563 色ごとのグループ
ユーザー かもめのうでかもめのうで
提出日時 2023-12-02 15:55:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 502 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 145,676 KB
最終ジャッジ日時 2023-12-02 15:55:28
合計ジャッジ時間 7,978 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 39 ms
53,460 KB
testcase_02 AC 41 ms
53,460 KB
testcase_03 AC 40 ms
53,460 KB
testcase_04 AC 38 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 36 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 60 ms
53,460 KB
testcase_10 AC 38 ms
53,460 KB
testcase_11 AC 41 ms
53,460 KB
testcase_12 AC 39 ms
53,460 KB
testcase_13 AC 38 ms
53,460 KB
testcase_14 AC 68 ms
70,912 KB
testcase_15 AC 69 ms
70,908 KB
testcase_16 AC 67 ms
70,912 KB
testcase_17 AC 67 ms
70,912 KB
testcase_18 AC 48 ms
62,356 KB
testcase_19 AC 72 ms
74,128 KB
testcase_20 AC 89 ms
80,068 KB
testcase_21 AC 91 ms
77,784 KB
testcase_22 AC 81 ms
76,816 KB
testcase_23 AC 90 ms
77,548 KB
testcase_24 AC 216 ms
95,036 KB
testcase_25 AC 192 ms
96,152 KB
testcase_26 AC 251 ms
104,612 KB
testcase_27 AC 272 ms
115,440 KB
testcase_28 AC 277 ms
107,832 KB
testcase_29 AC 374 ms
117,488 KB
testcase_30 AC 355 ms
117,616 KB
testcase_31 AC 360 ms
117,612 KB
testcase_32 AC 382 ms
117,484 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

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 += len(t)-1-e
print(ans)
0