제출 #63057

#제출 시각아이디문제언어결과실행 시간메모리
63057Bodo171Paths (BOI18_paths)C++14
53 / 100
246 ms30676 KiB
#include <iostream> #include <fstream> using namespace std; const int nmax=100005; long long dp[32][nmax]; int c[nmax],a[nmax],b[nmax]; int n,m,k,i,j,x,y; long long ans; int main() { //freopen("data.in","r",stdin); cin>>n>>m>>k; for(i=1;i<=n;i++) { cin>>c[i]; c[i]--; } for(i=1;i<=m;i++) { cin>>a[i]>>b[i]; } for(j=1;j<=n;j++) dp[(1<<c[j])][j]=1; for(i=1;i<(1<<k);i++) { if((i&(i-1))) for(j=1;j<=n;j++) ans+=dp[i][j]; for(j=1;j<=m;j++) { x=a[j];y=b[j]; if(((1<<c[x])&i)&&(!((1<<c[y])&i))) dp[i+(1<<c[y])][y]+=dp[i][x]; if((!((1<<c[x])&i))&&((1<<c[y])&i)) dp[i+(1<<c[x])][x]+=dp[i][y]; } } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...