fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
  6.  
  7. typedef long long ll;
  8.  
  9. vector<ll> g[200001];
  10. ll color[200001];
  11.  
  12. ll count = 0;
  13. ll visited[200001];
  14. ll countcolor[200001];
  15.  
  16. ll _max;
  17.  
  18.  
  19. ll dfs(ll x){
  20. visited[x] = 1;
  21. countcolor[color[x]]++;
  22. _max = max(_max,countcolor[color[x]]);
  23. ll co = 1;
  24. ll i;
  25. for(i = 0 ; i < g[x].size() ; i++){
  26. if(!visited[g[x][i]])
  27. co += dfs(g[x][i]);
  28. }
  29. return co;
  30. }
  31.  
  32.  
  33. int main(){
  34. boost;
  35. ll T,N,i,j,k,M,n,m,K;
  36. cin >> N >> M >> K;//
  37. for(i = 1 ; i <= N ; i++)
  38. cin >> color[i];
  39.  
  40. for(i = 0 ; i < M ; i++){
  41. ll l,r;
  42. cin >> l >> r;
  43. g[l].push_back(r);
  44. g[r].push_back(l);
  45. }
  46.  
  47.  
  48. ll ans = 0;
  49. for(i = 1 ; i <= N ; i++){
  50. if(visited[i] == 0){
  51. for(j = 1 ; j <= K ; j++)
  52. countcolor[j] = 0;
  53. _max = 0;
  54. ll v = dfs(i);
  55. ans += (v-_max);
  56. }
  57. }
  58.  
  59. cout << ans << endl;
  60. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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
stdout
Standard output is empty