#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
vector<ll> g[200001];
ll color[200001];
ll count = 0;
ll visited[200001];
ll countcolor[200001];
ll _max;
ll dfs(ll x){
visited[x] = 1;
countcolor[color[x]]++;
_max = max(_max,countcolor[color[x]]);
ll co = 1;
ll i;
for(i = 0 ; i < g[x].size() ; i++){
if(!visited[g[x][i]])
co += dfs(g[x][i]);
}
return co;
}
int main(){
boost;
ll T,N,i,j,k,M,n,m,K;
cin >> N >> M >> K;//
for(i = 1 ; i <= N ; i++)
cin >> color[i];
for(i = 0 ; i < M ; i++){
ll l,r;
cin >> l >> r;
g[l].push_back(r);
g[r].push_back(l);
}
ll ans = 0;
for(i = 1 ; i <= N ; i++){
if(visited[i] == 0){
for(j = 1 ; j <= K ; j++)
countcolor[j] = 0;
_max = 0;
ll v = dfs(i);
ans += (v-_max);
}
}
cout << ans << endl;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBib29zdCBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTtjaW4udGllKDApO2NvdXQudGllKDApCgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKCnZlY3RvcjxsbD4gZ1syMDAwMDFdOwpsbCBjb2xvclsyMDAwMDFdOwoKbGwgY291bnQgPSAwOwpsbCB2aXNpdGVkWzIwMDAwMV07CmxsIGNvdW50Y29sb3JbMjAwMDAxXTsKCmxsIF9tYXg7CgoKbGwgZGZzKGxsIHgpewogIHZpc2l0ZWRbeF0gPSAxOwogIGNvdW50Y29sb3JbY29sb3JbeF1dKys7CiAgX21heCA9IG1heChfbWF4LGNvdW50Y29sb3JbY29sb3JbeF1dKTsKICBsbCBjbyA9IDE7CiAgbGwgaTsKICBmb3IoaSA9IDAgOyBpIDwgZ1t4XS5zaXplKCkgOyBpKyspewogICAgaWYoIXZpc2l0ZWRbZ1t4XVtpXV0pCiAgICAgIGNvICs9IGRmcyhnW3hdW2ldKTsKICB9CiAgcmV0dXJuIGNvOwp9CgoKaW50IG1haW4oKXsKICBib29zdDsKICBsbCBULE4saSxqLGssTSxuLG0sSzsKICBjaW4gPj4gTiA+PiBNID4+IEs7Ly8KICBmb3IoaSA9IDEgOyBpIDw9IE4gOyBpKyspCiAgICBjaW4gPj4gY29sb3JbaV07CgogIGZvcihpID0gMCA7IGkgPCBNIDsgaSsrKXsKICAgIGxsIGwscjsKICAgIGNpbiA+PiBsID4+IHI7CiAgICBnW2xdLnB1c2hfYmFjayhyKTsKICAgIGdbcl0ucHVzaF9iYWNrKGwpOwogIH0KCgogIGxsIGFucyA9IDA7CiAgZm9yKGkgPSAxIDsgaSA8PSBOIDsgaSsrKXsKICAgIGlmKHZpc2l0ZWRbaV0gPT0gMCl7CiAgICAgIGZvcihqID0gMSA7IGogPD0gSyA7IGorKykKICAgICAgICBjb3VudGNvbG9yW2pdID0gMDsKICAgICAgX21heCA9IDA7CiAgICAgIGxsIHYgPSBkZnMoaSk7CiAgICAgIGFucyArPSAodi1fbWF4KTsKICAgIH0KICB9CgogIGNvdXQgPDwgYW5zIDw8IGVuZGw7Cn0=
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
^
Main.java:5: error: illegal character: '#'
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
^
Main.java:5: error: class, interface, or enum expected
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
^
Main.java:5: error: class, interface, or enum expected
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
^
Main.java:5: error: class, interface, or enum expected
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
^
Main.java:9: error: class, interface, or enum expected
vector<ll> g[200001];
^
Main.java:10: error: class, interface, or enum expected
ll color[200001];
^
Main.java:12: error: class, interface, or enum expected
ll count = 0;
^
Main.java:13: error: class, interface, or enum expected
ll visited[200001];
^
Main.java:14: error: class, interface, or enum expected
ll countcolor[200001];
^
Main.java:16: error: class, interface, or enum expected
ll _max;
^
Main.java:19: error: class, interface, or enum expected
ll dfs(ll x){
^
Main.java:21: error: class, interface, or enum expected
countcolor[color[x]]++;
^
Main.java:22: error: class, interface, or enum expected
_max = max(_max,countcolor[color[x]]);
^
Main.java:23: error: class, interface, or enum expected
ll co = 1;
^
Main.java:24: error: class, interface, or enum expected
ll i;
^
Main.java:25: error: class, interface, or enum expected
for(i = 0 ; i < g[x].size() ; i++){
^
Main.java:25: error: class, interface, or enum expected
for(i = 0 ; i < g[x].size() ; i++){
^
Main.java:25: error: class, interface, or enum expected
for(i = 0 ; i < g[x].size() ; i++){
^
Main.java:28: error: class, interface, or enum expected
}
^
Main.java:30: error: class, interface, or enum expected
}
^
Main.java:35: error: class, interface, or enum expected
ll T,N,i,j,k,M,n,m,K;
^
Main.java:36: error: class, interface, or enum expected
cin >> N >> M >> K;//
^
Main.java:37: error: class, interface, or enum expected
for(i = 1 ; i <= N ; i++)
^
Main.java:37: error: class, interface, or enum expected
for(i = 1 ; i <= N ; i++)
^
Main.java:37: error: class, interface, or enum expected
for(i = 1 ; i <= N ; i++)
^
Main.java:40: error: class, interface, or enum expected
for(i = 0 ; i < M ; i++){
^
Main.java:40: error: class, interface, or enum expected
for(i = 0 ; i < M ; i++){
^
Main.java:40: error: class, interface, or enum expected
for(i = 0 ; i < M ; i++){
^
Main.java:42: error: class, interface, or enum expected
cin >> l >> r;
^
Main.java:43: error: class, interface, or enum expected
g[l].push_back(r);
^
Main.java:44: error: class, interface, or enum expected
g[r].push_back(l);
^
Main.java:45: error: class, interface, or enum expected
}
^
Main.java:49: error: class, interface, or enum expected
for(i = 1 ; i <= N ; i++){
^
Main.java:49: error: class, interface, or enum expected
for(i = 1 ; i <= N ; i++){
^
Main.java:49: error: class, interface, or enum expected
for(i = 1 ; i <= N ; i++){
^
Main.java:51: error: class, interface, or enum expected
for(j = 1 ; j <= K ; j++)
^
Main.java:51: error: class, interface, or enum expected
for(j = 1 ; j <= K ; j++)
^
Main.java:53: error: class, interface, or enum expected
_max = 0;
^
Main.java:54: error: class, interface, or enum expected
ll v = dfs(i);
^
Main.java:55: error: class, interface, or enum expected
ans += (v-_max);
^
Main.java:56: error: class, interface, or enum expected
}
^
Main.java:60: error: class, interface, or enum expected
}
^
44 errors