#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector <int> adj[maxn];
int dp[maxn][32];
int c[maxn];
int n, m , k;
int main(){
cin >> n >> m >> k;
for(int i = 1; i <= n; i++){
cin >> c[i];
c[i]--;
dp[i][1 << c[i]] = 1;
}
for(int i = 1; i <= m; i++){
int a, b;
cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
long long ans = 0;
for(int mask = 1; mask < (1 << k); mask++){
for(int i = 1; i <= n; i++){
if(mask & (1 << c[i])){
for(int u : adj[i]){
dp[i][mask] += dp[u][mask ^ (1 << c[i])];
}
ans += dp[i][mask];
}
}
}
cout << ans - n << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
3 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
3 ms |
2644 KB |
Output is correct |
5 |
Correct |
3 ms |
2656 KB |
Output is correct |
6 |
Correct |
3 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
8 |
Correct |
3 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
3 ms |
2660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
187 ms |
9764 KB |
Output is correct |
2 |
Correct |
141 ms |
8520 KB |
Output is correct |
3 |
Runtime error |
38 ms |
31436 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
3 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
3 ms |
2644 KB |
Output is correct |
5 |
Correct |
3 ms |
2656 KB |
Output is correct |
6 |
Correct |
3 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
8 |
Correct |
3 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
3 ms |
2660 KB |
Output is correct |
11 |
Correct |
187 ms |
9764 KB |
Output is correct |
12 |
Correct |
141 ms |
8520 KB |
Output is correct |
13 |
Runtime error |
38 ms |
31436 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
49 ms |
4480 KB |
Output is correct |
3 |
Correct |
42 ms |
4428 KB |
Output is correct |
4 |
Correct |
126 ms |
19640 KB |
Output is correct |
5 |
Correct |
98 ms |
20376 KB |
Output is correct |
6 |
Correct |
175 ms |
19684 KB |
Output is correct |
7 |
Correct |
42 ms |
4564 KB |
Output is correct |
8 |
Correct |
137 ms |
19632 KB |
Output is correct |
9 |
Correct |
109 ms |
20444 KB |
Output is correct |
10 |
Correct |
128 ms |
20528 KB |
Output is correct |
11 |
Correct |
95 ms |
11992 KB |
Output is correct |
12 |
Correct |
124 ms |
16376 KB |
Output is correct |
13 |
Correct |
108 ms |
12276 KB |
Output is correct |
14 |
Correct |
167 ms |
19588 KB |
Output is correct |
15 |
Correct |
227 ms |
19772 KB |
Output is correct |
16 |
Correct |
2 ms |
2644 KB |
Output is correct |
17 |
Correct |
2 ms |
2644 KB |
Output is correct |
18 |
Correct |
2 ms |
2644 KB |
Output is correct |
19 |
Correct |
2 ms |
2644 KB |
Output is correct |
20 |
Correct |
2 ms |
2644 KB |
Output is correct |
21 |
Correct |
2 ms |
2656 KB |
Output is correct |
22 |
Correct |
2 ms |
2652 KB |
Output is correct |
23 |
Correct |
2 ms |
2656 KB |
Output is correct |
24 |
Correct |
2 ms |
2660 KB |
Output is correct |
25 |
Correct |
2 ms |
2772 KB |
Output is correct |