이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=3e5+7;
vector<int>V[LIM];
int T[LIM], dp[LIM][1<<5];
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
rep(i, n) {
cin >> T[i]; --T[i];
dp[i][1<<T[i]]=1;
}
rep(i, m) {
int a, b;
cin >> a >> b; --a; --b;
V[a].pb(b);
V[b].pb(a);
}
int ans=0;
for(int i=1; i<(1<<k); ++i) {
rep(j, n) {
if(__builtin_popcount(i)>1) ans+=dp[j][i];
for(auto l : V[j]) if(!(i&(1<<T[l]))) {
dp[l][i+(1<<T[l])]+=dp[j][i];
}
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |