#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector <int> adj[maxn];
int n, k , m;
long long ans = 0;
int c[maxn] , cl[6] ,dive = 0;
bool mark[maxn];
void dfs(int v){
if(dive == k)return;
if(mark[v])return;
dive++;
mark[v] = 1;
cl[c[v]]++;
for(int u : adj[v])
dfs(u);
if(cl[1] <= 1 and cl[2] <= 1 and cl[3] <= 1 and cl[4] <= 1 and cl[5] <= 1 and dive > 1)
ans++;
mark[v] = 0;
cl[c[v]]--;
dive--;
}
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >> n >> m >> k;
for(int i = 0; i < n; i++)
cin >> c[i + 1];
for(int i = 0; i < m; i++){
int a, b; cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
for(int i = 0; i < n; i++){
dfs(i + 1);
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3058 ms |
6312 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
2 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Execution timed out |
3058 ms |
6312 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Execution timed out |
3064 ms |
3696 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |