Submission #703202

#TimeUsernameProblemLanguageResultExecution timeMemory
703202beaconmcPaths (BOI18_paths)C++14
100 / 100
776 ms100604 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> typedef long long ll; using namespace std; //using namespace __gnu_pbds; #define FOR(i, x, y) for(ll i=x; i<y; i++) #define FORNEG(i, x, y) for(ll i=x; i>y; i--) //#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL) ll dp[32][300001]; vector<ll> edges[300001]; vector<ll> colours; int main(){ ll n,m,k; cin >> n >> m >> k; FOR(i,0,n){ ll temp; cin >> temp; colours.push_back(temp-1); } FOR(i,0,m){ ll a,b; cin >> a >> b; a--;b--; edges[a].push_back(b); edges[b].push_back(a); } FOR(i,0,32) FOR(j,0,300001) dp[i][j] = 0; FOR(i,0,n){ dp[1<<colours[i]][i] = 1; } FOR(p,1, 1<<k){ FOR(i,0,n){ for (auto&j : edges[i]){ FOR(q, 1, 1<<k){ if ((q|(1<<colours[i])) == p && ((q&(1<<colours[i])) == 0)){ dp[p][i] += dp[q][j]; } } } } } ll ans = 0; FOR(i,0,1<<k){ if (i==1 || i==2 || i==4 || i==8 || i==16) continue; FOR(j,0,n){ ans += dp[i][j]; } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...