# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
852112 | Benmath | Paths (BOI18_paths) | C++14 | 832 ms | 1048576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
long long int brojac = 0;
int n;
int m;
int k;
int boja[10];
int koja_boja[300005];
vector<int>adjl[300005];
void dfs(int s){
// cout << s << endl;
boja[s]++;
brojac++;
for (int i = 0; i < adjl[s].size(); i++){
if(boja[koja_boja[adjl[s][i]]] == 0){
dfs(adjl[s][i]);
boja[koja_boja[adjl[s][i]]] = 0;
}
}
}
int main()
{
cin >> n >> m >> k;
for(int i = 1; i <= n; i++){
cin >> koja_boja[i];
}
for (int i = 0; i < m; i++){
int x, y;
cin >> x >> y;
adjl[x].push_back(y);
adjl[y].push_back(x);
}
for (int i = 1; i <= n; i++){
for (int j = 1; j <= k; j++){
boja[j] = 0;
}
dfs(i);
brojac--;
}
cout << brojac;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |