diff --git a/Luogu/P6569/P6569.cpp b/Luogu/P6569/P6569.cpp new file mode 100644 index 00000000..1597dbcf --- /dev/null +++ b/Luogu/P6569/P6569.cpp @@ -0,0 +1,88 @@ +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +struct Matrix : public std::vector> { + int n, m; + + Matrix(const int &_n = 0, const int &_m = 0) + : std::vector>(_n, std::vector(_m)), + n(_n), + m(_m) {} + + Matrix(const Matrix &_matrix) + : std::vector>(_matrix), n(_matrix.n), m(_matrix.m) {} + + Matrix operator=(const Matrix &_matrix) { + std::vector>::operator=(_matrix); + n = _matrix.n; + m = _matrix.m; + + return *this; + } + + Matrix operator^(Matrix rhs) { + Matrix res(n, rhs.m); + + for (int i = 0; i < n; ++i) { + for (int j = 0; j < rhs.m; ++j) { + res[i][j] = 0; + + for (int k = 0; k < m; ++k) { + res[i][j] ^= (*this)[i][k] * rhs[k][j]; + } + } + } + + return res; + } +}; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + int n, m, q; + std::vector a; + + cin >> n >> m >> q; + + std::copy_n(std::istream_iterator(cin), n, std::back_inserter(a)); + + std::vector g; + g.emplace_back(n, n); + + for (int i = 1, u, v; i <= m; i++) { + cin >> u >> v; + + u--, v--; + + g[0][u][v] = g[0][v][u] = 1; + } + + for (int i = 1; i <= 32; i++) { + g.emplace_back(g.back() ^ g.back()); + } + + while (q--) { + long long x; + + cin >> x; + + Matrix f(1, n); + f[0] = a; + + for (long long w = 1, i = 0; w <= x; w <<= 1, i++) { + if (x & w) f = f ^ g[i]; + } + + cout << f[0][0] << endl; + } + + return 0; +} diff --git a/Luogu/P6569/data/P6569_2.in b/Luogu/P6569/data/P6569_2.in new file mode 100644 index 00000000..8debc94d --- /dev/null +++ b/Luogu/P6569/data/P6569_2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0dec88e6a245a0b2b69c3b7b4c79c21e83080de67bc162649c4f0c4fe4937464 +size 573 diff --git a/Luogu/P6569/data/P6569_2.out b/Luogu/P6569/data/P6569_2.out new file mode 100644 index 00000000..f8cc6f2c --- /dev/null +++ b/Luogu/P6569/data/P6569_2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd210886b8e17065b5452a68168d43e3bccdf867946ecd3324b39de5a2645a32 +size 318