제출 #1142964

#제출 시각아이디문제언어결과실행 시간메모리
1142964vladiliusPaths (BOI18_paths)C++20
100 / 100
195 ms66340 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k; cin>>n>>m>>k; vector<int> a(n + 1); for (int i = 1; i <= n; i++){ cin>>a[i]; a[i]--; } vector<int> g[n + 1]; while (m--){ int x, y; cin>>x>>y; g[x].pb(y); g[y].pb(x); } vector<vector<ll>> dp(n + 1, vector<ll>(1 << k)); ll out = 0; for (int x = 1; x < (1 << k); x++){ for (int i = 1; i <= n; i++){ if ((1 << a[i]) & x){ int f = x - (1 << a[i]); if (!f){ dp[i][x] = 1; continue; } for (int j: g[i]){ dp[i][x] += dp[j][f]; } out += dp[i][x]; } } } cout<<out<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...