#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++){
if(__builtin_popcount(mask) == 1) continue;
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 << 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 |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
1 ms |
2644 KB |
Output is correct |
7 |
Correct |
1 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 |
1 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
150 ms |
6864 KB |
Output is correct |
2 |
Correct |
121 ms |
6268 KB |
Output is correct |
3 |
Runtime error |
35 ms |
31256 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 |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
1 ms |
2644 KB |
Output is correct |
7 |
Correct |
1 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 |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
150 ms |
6864 KB |
Output is correct |
12 |
Correct |
121 ms |
6268 KB |
Output is correct |
13 |
Runtime error |
35 ms |
31256 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
43 ms |
3784 KB |
Output is correct |
3 |
Correct |
49 ms |
3812 KB |
Output is correct |
4 |
Correct |
99 ms |
18304 KB |
Output is correct |
5 |
Correct |
92 ms |
18964 KB |
Output is correct |
6 |
Correct |
167 ms |
18336 KB |
Output is correct |
7 |
Correct |
43 ms |
3824 KB |
Output is correct |
8 |
Correct |
135 ms |
18336 KB |
Output is correct |
9 |
Correct |
111 ms |
19000 KB |
Output is correct |
10 |
Correct |
106 ms |
19120 KB |
Output is correct |
11 |
Correct |
92 ms |
10952 KB |
Output is correct |
12 |
Correct |
114 ms |
14984 KB |
Output is correct |
13 |
Correct |
104 ms |
11088 KB |
Output is correct |
14 |
Correct |
164 ms |
18232 KB |
Output is correct |
15 |
Correct |
162 ms |
18524 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 |
2600 KB |
Output is correct |
20 |
Correct |
2 ms |
2644 KB |
Output is correct |
21 |
Correct |
2 ms |
2644 KB |
Output is correct |
22 |
Correct |
2 ms |
2644 KB |
Output is correct |
23 |
Correct |
1 ms |
2644 KB |
Output is correct |
24 |
Correct |
2 ms |
2644 KB |
Output is correct |
25 |
Correct |
1 ms |
2644 KB |
Output is correct |