# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
513741 | 2022-01-17T13:30:54 Z | ahmeteren | Paths (BOI18_paths) | C++17 | 12 ms | 14868 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long const int N = 3e5 + 5; ll dp[N][(1 << 5)], c[N]; vector<int> vec[N]; ll dfs(int node, int mask) { if((mask & (1 << c[node])) == 0) return 0; if(mask == (1 << c[node])) return 1; if(dp[node][mask] != -1) return dp[node][mask]; dp[node][mask] = 0; for(auto to : vec[node]) { dp[node][mask] += dfs(to, mask ^ (1 << c[node])); } return dp[node][mask]; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif int n, m, k; cin >> n >> m >> k; for(int i = 1; i <= n; i++) { cin >> c[i]; c[i]--; } for(int i = 1; i <= m; i++) { int u, v; cin >> u >> v; vec[u].push_back(v); vec[v].push_back(u); } memset(dp, -1, sizeof(dp)); ll cevap = 0; for(int i = 1; i <= n; i++) { for(int j = 1; j < (1 << k); j++) { cevap += dfs(i, j); } } cout << cevap - n << '\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 12 ms | 14860 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 12 ms | 14868 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 12 ms | 14860 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 12 ms | 14796 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |