Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cassert>
- #include <cstdio>
- #include <cstring>
- #include <cstdlib>
- #include <cmath>
- #include <ctime>
- #include <cctype>
- #include <algorithm>
- #include <tuple>
- #include <random>
- #include <bitset>
- #include <chrono>
- #include <queue>
- #include <functional>
- #include <set>
- #include <map>
- #include <vector>
- #include <iostream>
- #include <limits>
- #include <numeric>
- #ifdef LBT
- #define LOG(FMT...) fprintf(stderr, FMT)
- #else
- #define LOG(FMT...)
- #endif
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
- const int N = 21, P = 998244353;
- int n, x, y;
- int inv[N + 1], fac[N + 1], ifac[N + 1], pwx[N + 1], pwy[N + 1];
- int a[1 << N][N + 1];
- int cnt[1 << N];
- bool g[N][N];
- int as[N];
- int norm(int x) { return x >= P ? x - P : x; }
- void exGcd(int a, int b, int& x, int& y) {
- if (!b) {
- x = 1; y = 0;
- return;
- }
- exGcd(b, a % b, y, x);
- y -= a / b * x;
- }
- int ginv(int a) {
- int x, y;
- exGcd(a, P, x, y);
- return norm(x + P);
- }
- void pln(int* a, int* b) {
- static int tmp[N + 1];
- for (int i = 0; i < n; ++i) {
- tmp[i] = a[i + 1] * (i + 1LL) % P;
- for (int j = 1; j <= i; ++j)
- tmp[i] = (tmp[i] + P - tmp[i - j] * (ll)a[j] % P) % P;
- }
- for (int i = n; i; --i)
- b[i] = tmp[i - 1] * (ll)inv[i] % P;
- b[0] = 0;
- }
- // G' = G * f'
- void pexp(int* a, int* b) {
- static int tmp[N + 1];
- tmp[0] = 1;
- for (int i = 1; i <= n; ++i) {
- tmp[i] = 0;
- for (int j = 1; j <= i; ++j)
- tmp[i] = (tmp[i] + tmp[i - j] * (ll)a[j] % P * j) % P;
- tmp[i] = tmp[i] * (ll)inv[i] % P;
- }
- memcpy(b, tmp, sizeof(tmp));
- }
- void prepare(int n) {
- inv[1] = 1;
- for (int i = 2; i <= n; ++i)
- inv[i] = -(P / i) * (ll)inv[P % i] % P + P;
- fac[0] = 1;
- for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * (ll)i % P;
- ifac[0] = 1;
- for (int i = 1; i <= n; ++i) ifac[i] = ifac[i - 1] * (ll)inv[i] % P;
- pwx[0] = 1;
- for (int i = 1; i <= n; ++i)
- pwx[i] = pwx[i - 1] * (ll)x % P;
- pwy[0] = 1;
- for (int i = 1; i <= n; ++i)
- pwy[i] = pwy[i - 1] * (ll)y % P;
- for (int i = 1; i < 1 << n; ++i)
- cnt[i] = cnt[i >> 1] + (i & 1);
- }
- int main() {
- #ifdef LBT
- freopen("test.in", "r", stdin);
- int nol_cl = clock();
- #endif
- scanf("%d", &n);
- for (int i = 0; i < n; ++i) {
- for (int j = 0; j < n; ++j)
- scanf("%d", &g[i][j]);
- for (int j = 0; j < n; ++j)
- as[i] |= g[i][j] << j;
- }
- scanf("%d%d", &x, &y);
- prepare(n);
- for (int s = 0; s < 1 << n; ++s) {
- int cn = 0;
- for (int i = 0; i < n; ++i) {
- }
- }
- #ifdef LBT
- LOG("Time: %dms\n", int ((clock()
- -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment