# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
505941 |
2022-01-11T10:52:04 Z |
MurotY |
Paths (BOI18_paths) |
C++14 |
|
3000 ms |
14944 KB |
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ff first
#define ss second
using namespace std;
const int N=2*1e5+7;
vector <ll> g[N];
map <ll,ll> mp;
ll c[N];
bool u[N], u1[N];
ll res=0, ans=0;
void dfs(ll v){
u[v]=1;
if (mp[c[v]] == 0) res++;
else {
u[v]=0;
return ;
}
mp[c[v]]++;
// cout << c[q] <<" " << c[v] << q <<"\n";
for (auto l:g[v]){
if (!u[l]){
dfs(l);
}
}
u[v]=0;
mp[c[v]]=0;
return;
}
int main()
{
int n, m, k;
cin >> n >> m >> k;
for (int i=1;i<=n;i++) cin >> c[i];
for (int i=1;i<=m;i++){
int x, y;
cin >> x >> y;
g[x].push_back(y);
g[y].push_back(x);
}
for (int i=1;i<=n;i++){
res=-1;
mp.clear();
// fill(u1,u1+n+1, 0);
dfs(i);
// cout << res <<" ";
ans+=res;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
3 ms |
4940 KB |
Output is correct |
6 |
Correct |
3 ms |
4940 KB |
Output is correct |
7 |
Correct |
3 ms |
4940 KB |
Output is correct |
8 |
Correct |
5 ms |
4940 KB |
Output is correct |
9 |
Correct |
3 ms |
4940 KB |
Output is correct |
10 |
Correct |
3 ms |
4940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3030 ms |
14944 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
3 ms |
4940 KB |
Output is correct |
6 |
Correct |
3 ms |
4940 KB |
Output is correct |
7 |
Correct |
3 ms |
4940 KB |
Output is correct |
8 |
Correct |
5 ms |
4940 KB |
Output is correct |
9 |
Correct |
3 ms |
4940 KB |
Output is correct |
10 |
Correct |
3 ms |
4940 KB |
Output is correct |
11 |
Execution timed out |
3030 ms |
14944 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4996 KB |
Output is correct |
2 |
Execution timed out |
3102 ms |
7896 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |