Submission #869226

#TimeUsernameProblemLanguageResultExecution timeMemory
869226sleepntsheepPaths (BOI18_paths)C++17
0 / 100
222 ms158804 KiB
#include <iostream> #include <cstring> #include <vector> #include <algorithm> #include <deque> #include <set> #include <utility> #include <array> #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx2,tune=native") 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[2][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) for (int s = 0; s < (1<<k); ++s) d[i&1][j][s] = 0; 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) { ll X = !((s>>c[v])&1)*d[!(i&1)][u][s]; d[i&1][v][s|(1<<c[v])] += X, z += X; } } } 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...