# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1034642 | 2024-07-25T15:44:51 Z | anango | Paths (BOI18_paths) | C++17 | 1 ms | 604 KB |
#include <bits/stdc++.h> #define int long long using namespace std; int INF = 1LL<<30; signed main() { #ifndef ONLINE_JUDGE // for getting input from input.txt freopen("input.txt", "r", stdin); // for writing output to output.txt freopen("output.txt", "w", stdout); #endif #ifdef ONLINE_JUDGE ios_base::sync_with_stdio(false); cin.tie(NULL); #endif //fast IO int n,m,k; cin >> n >> m >> k; vector<vector<int>> adjlist(n); vector<int> col(n); for (int i=0; i<n; i++) {cin >> col[i]; col[i]--;} for (int i=0; i<m; i++) { int u,v; cin >> u >> v; u--; v--; adjlist[u].push_back(v); adjlist[v].push_back(u); } int dp[n][1<<k]; for (int i=0; i<n; i++) { for (int j=0; j<1<<k; j++) { dp[i][j] = 0; } } //dp[i][j] = number of paths with this bitmask of colours used, ending in this vertex for (int i=0; i<n; i++) { dp[i][1<<col[i]]++; } for (int mask=1; mask<1<<k; mask++) { for (int i=0; i<n; i++) { if (mask&(1<<col[i])==0) continue; for (int j:adjlist[i]) { dp[i][mask]+=dp[j][mask^(1<<col[i])]; } } } int su=0; for (int i=0; i<n; i++) { for (int j=0; j<1<<k; j++) { su+=dp[i][j]; } } cout << su-n << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 600 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 604 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 600 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 600 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |