// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
using ll = int64_t;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N, M, K; cin >> N >> M >> K;
vector<int> A(N); for(auto& x : A) { cin >> x; --x; }
vector<vector<int>> adj(N);
for(int i = 0; i < M; i++) {
int u, v; cin >> u >> v; --u, --v;
// cout << u << " " << v << nl;
adj[u].push_back(v);
adj[v].push_back(u);
}
vector<vector<ll>> dp(N, vector<ll>(1<<K, 0));
for(int i = 0; i < N; i++) dp[i][1<<A[i]] = 1;
ll ans = 0;
int P2 = 1;
for(int s = 1; s < (1<<K); s++) {
for(int u = 0; u < N; u++) if (dp[u][s] != 0) {
if (s == P2) { ans += dp[u][s]; P2 += P2; }
for(const auto &v : adj[u]) if (((s >> A[v]) & 1) ^ 1) dp[v][s^(1<<A[v])] += dp[u][s];
}
}
cout << ans << nl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
66 ms |
4220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |