QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#504787#9112. Zayin and RafflePlentyOfPenalty#WA 2937ms11116kbC++203.9kb2024-08-04 15:58:322024-08-04 15:58:33

Judging History

你现在查看的是最新测评结果

  • [2024-08-04 15:58:33]
  • 评测
  • 测评结果:WA
  • 用时:2937ms
  • 内存:11116kb
  • [2024-08-04 15:58:32]
  • 提交

answer

#include <bits/stdc++.h>
#include <string>
#define all(x) begin(x), end(x)
#define rep(i, l, r) for (int i = (l), i##end = (r); i <= i##end; ++i)
#define per(i, l, r) for (int i = (l), i##end = (r); i >= i##end; --i)
#ifdef memset0
#define log(...) fprintf(stderr, __VA_ARGS__)
#else
#define log(...) (void(0))
#define endl '\n'
#endif
using namespace std;
using ll = long long;
using lf = long double;
using ull = unsigned long long;
const int N = 1e5;
const int M = 16;
const int K = 8;
const int mod = 1e9 + 7;
const int tg = 2, itg = (mod + 1) / tg;
int n, m, k, p[K + 10], s[(1 << K) + 10], inv[(1 << K) + 10];
int a[N + 10][K + 10], cnt[(1 << K) + 10];
int cs[(1 << K) + 10], lb[(1 << K) + 10];
int mv[(1 << M) + 10], ok[(1 << M) + 10];
int nd, rs;
string prt(int x, int y) {
  string ret;
  for (int i = 0; i < y; ++i) ret += ((x >> i) & 1) + '0';
  return ret;
}
int POW(int x, int y) {
  int ret = 1;
  while (y) y & 1 ? ret = 1ll * ret * x % mod : 0, x = 1ll * x * x % mod, y >>= 1;
  return ret;
}
int nt(int x, int y) { return (~x) & ((1 << y) - 1); }
void Ins(int x, int v) {
  // cerr << "INS " << prt(x, m) << " " << v << "\n";
  x &= rs;
  mv[x] = 1ll * mv[x] * v % mod;
  // cerr << "=" << mv[x] << "\n";
}
void Tag(int x, int v) {
  // cerr << "Tag " << prt(x, m) << " " << v << "\n";
  x &= rs;
  ok[x] = 1ll * ok[x] * v % mod;
  // cerr << "=" << ok[x] << "\n";
}
int main() {
#ifdef memset0
  freopen("L.in", "r", stdin);
#endif
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> m >> k;
  for (int i = 0; i < k; ++i) {
    cin >> p[i];
  }
  for (int i = 1; i < (1 << k); ++i) {
    cnt[i] = (cnt[i >> 1] ^ (i & 1));
    lb[i] = ((i & 1) ? 0 : (lb[i >> 1] + 1));
    s[i] = s[i - (1 << lb[i])] + p[lb[i]];
    inv[i] = POW(s[i], mod - 2);
  }
  rs = (1 << m) - 1;
  for (int i = 1; i <= n; ++i) {
    nd = 0;
    for (int j = 0; j < k; ++j) cin >> a[i][j], nd |= nt(a[i][j], m);
    // rs &= nd;
  }
  // cerr << "RS=" << prt(rs, m) << "\n";
  for (int i = 0; i < (1 << m); ++i) mv[i] = ok[i] = 1;
  for (int i = 1; i <= n; ++i) {
    // cerr << ">>>>>>>>>>>>>>>>>>>>>>>i=" << i << "\n";
    cs[0] = (1 << k) - 1;
    for (int j = 1; j < (1 << k); ++j) {
      cs[j] = (cs[j - (1 << lb[j])] & nt(a[i][lb[j]], m));
      // cerr << "CS " << j << "=" << prt(cs[j], m) << "\n";
    }
    for (int j = 1; j < (1 << k); ++j) {
      int rv = nt(j, k);
      Ins(cs[j], s[j]);
      Tag(cs[j], tg);
      for (int t = rv; t; t = (t - 1) & rv) {
        Ins(cs[j | t], cnt[t] ? inv[j] : s[j]);
        Tag(cs[j | t], cnt[t] ? itg : tg);
      }
    }
  }
  /*cerr << "--------------------------OK calc\n";
  for (int i = 0; i < (1 << m); ++i) {
    if ((i | rs) == rs) assert(mv[i]);
    cerr << "dlt mv " << prt(i, m) << "=" << mv[i] << "\n";
  }*/
  for (int i = 0; i < m; ++i)
    if (rs & (1 << i)) {
      for (int j = (1 << m) - 1; j >= 0; --j)
        if ((j | rs) == rs && !(j & (1 << i))) {
          mv[j] = 1ll * mv[j] * mv[j | (1 << i)] % mod;
          ok[j] = 1ll * ok[j] * ok[j | (1 << i)] % mod;
          // cerr << "MV " << prt(j, m) << "*=" << prt(j | (1 << i), m) << "=" << mv[j] << "\n";
        }
    }
  /*for (int i = 0; i < m; ++i)
    for (int j = (1 << m) - 1; j >= 0; --j)
      if (!(j & (1 << i))) mv[j] += mv[j | (1 << i)];*/
  int chk = POW(tg, n);
  for (int i = 0; i < (1 << m); ++i) {
    if (ok[i] != chk) mv[i] = 0;
  }
  for (int i = m - 1; i >= 0; --i) {
    for (int j = 0; j < (1 << m); ++j) {
      if (!(j & (1 << i))) (mv[j] -= mv[j | (1 << i)]) < 0 ? mv[j] += mod : 0;
    }
  }
  /*cerr << "----------------------------OK pre\n";
  for (int i = 0; i < (1 << m); ++i) {
    cerr << "prob " << prt(i, m) << "=" << mv[i] << "\n";
  }*/
  int dv = POW(POW(1000000000, mod - 2), n);
  // int dv = POW(POW(5, mod - 2), n);
  // cerr << "DV=" << dv << "\n";
  for (int i = 0; i < (1 << m); ++i) cout << 1ll * mv[nt(i, m)] * dv % mod << "\n";
}

详细

Test #1:

score: 0
Wrong Answer
time: 2937ms
memory: 11116kb

input:

100000 16 8
14837 17850 15180 22820 26722 4874 4574 999893143
15006 45877 19815 26604 6797 0 25449 15769
26395 0 495 64118 18133 47822 5863 39708
56443 188 55498 14620 36924 25033 0 36587
55421 21544 59411 3280 55222 0 51028 55986
42323 41153 53683 16144 53188 15759 0 28378
63709 51900 0 18592 1916 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 1st lines differ - expected: '105532035', found: '0'