Submission #869224

#TimeUsernameProblemLanguageResultExecution timeMemory
869224sleepntsheepPaths (BOI18_paths)C++17
100 / 100
530 ms397536 KiB
#include <iostream> #include <cstring> #include <vector> #include <algorithm> #include <deque> #include <set> #include <utility> #include <array> using namespace std; #define ALL(x) x.begin(), x.end() #define ShinLena cin.tie(nullptr)->sync_with_stdio(false); using ll = long long; #define N 300005 int n, m, k, c[N]; ll d[6][N][33],z; array<int, 2> el[N]; int main() { ShinLena; cin >> n >> m >> k; for (int i = 1; i <= n; ++i) cin >> c[i], d[0][i][1<<--c[i]] = 1; for (int i = 0; i < m; ++i) cin >> el[i][0] >> el[i][1]; for (int i = 1; i <= k; ++i) { for (int j = 0; j < m; ++j) { auto [u, v] = el[j]; for (int J = 2; J--; swap(u, v)) for (int s = 0; s < (1<<k); ++s) d[i][v][s|(1<<c[v])] += !((s>>c[v])&1)*d[i-1][u][s]; } } for (int j = 1; j <= k; ++j) for (int i = 1; i <= n; ++i) for (int s = 0; s < (1 << k); ++s) z += d[j][i][s]; cout << z; 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...