# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
538188 | new_acc | Paths (BOI18_paths) | C++14 | 288 ms | 31420 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e5+10;
ll dp[1<<5][N];
vi graf[N];
int k[N];
void solve(){
int n,m,kk;
cin>>n>>m>>kk;
for(int i=1;i<=n;i++) cin>>k[i];
for(int i=1,a,b,c;i<=m;i++){
cin>>a>>b;
graf[a].push_back(b),graf[b].push_back(a);
}
ll res=0;
for(int i=1;i<(1<<kk);i++){
for(int wsk=1;wsk<=n;wsk++){
if((1<<(k[wsk]-1))&i){
if(__builtin_popcount(i)==1) dp[i][wsk]=1;
else for(auto u:graf[wsk]) dp[i][wsk]+=dp[i-(1<<(k[wsk]-1))][u];
}
res+=dp[i][wsk];
}
}
cout<<res-n<<"\n";
}
int main(){
solve();
}
Compilation message (stderr)
# | 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... |