QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#507128 | #9112. Zayin and Raffle | IllusionaryDominance | AC ✓ | 1891ms | 140492kb | C++14 | 1.9kb | 2024-08-06 11:20:43 | 2024-08-06 11:20:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 1e5 + 10;
const int M = (1 << 16) + 10;
const int K = (1 << 8) + 10;
long long ksm(long long x, long long y){
long long re = 1;
for (; y; y >>= 1){
if(y & 1) re = re * x % MOD;
x = x * x % MOD;
}
return re;
}
const long long dv = ksm(1e9, MOD - 2);
long long tot[M][K], p[K], ans[M];
int main(){
ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
// freopen("1.txt", "r", stdin);
// freopen("2.txt", "w", stdout);
int n, m, k;
cin >> n >> m >> k;
for (int i = 0; i < k; ++ i){
long long _p; cin >> _p, _p = _p * dv % MOD;
for (int j = (1 << i); j < (1 << k); j = ((j + 1) | (1 << i))) (p[j] += _p) %= MOD;
}
for (int i = 0; i < (1 << m); ++ i) ans[i] = 1;
for (int i = 1; i <= n; ++ i){
vector<int> a(k);
for (int j = 0; j < k; ++ j) cin >> a[j];
for (int j = 0; j < (1 << k); ++ j){
int S = 0;
for (int l = 0; l < k; ++ l) if((j >> l) & 1) S |= a[l];
++ tot[S][j];
}
}
for (int S = 0; S < (1 << m); ++ S)
for (int i = 0; i < k; ++ i)
for (int s = 0; s < (1 << k); ++ s) if((s >> i) & 1) (tot[S][s ^ (1 << i)] += MOD - tot[S][s]) %= MOD;
for (int S = 0; S < (1 << k); ++ S)
for (int i = 0; i < m; ++ i)
for (int s = 0; s < (1 << m); ++ s) if((s >> i) & 1) (tot[s][S] += tot[s ^ (1 << i)][S]) %= MOD;
for (int i = 0; i < (1 << k); ++ i)
for (int j = 0; j < (1 << m); ++ j)
(ans[j] *= ksm(p[i], tot[j][i])) %= MOD;
for (int i = 0; i < m; ++ i)
for (int s = 0; s < (1 << m); ++ s) if((s >> i) & 1) (ans[s] += MOD - ans[s ^ (1 << i)]) %= MOD;
for (int i = 0; i < (1 << m); ++ i) cout << ans[i] << "\n";
}
/*
2 2 2
400000000 600000000
1 0
2 1
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1783ms
memory: 140240kb
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:
105532035 709209358 742395693 674439956 829972983 268323536 719611672 686061778 667639364 160529448 284006277 426487374 560675131 711436547 151999054 83251935 704825434 897033675 576472928 375148047 149541480 425599467 975644650 421255417 560324160 127313981 870564235 441704026 939196723 26709030 47...
result:
ok 65536 lines
Test #2:
score: 0
Accepted
time: 1891ms
memory: 140492kb
input:
100000 16 8 14266 4655 1910 6044 23911 5824 16951 999926439 2048 0 1792 49290 734 9216 288 55841 8 16530 5376 32785 289 0 320 8193 0 4 4 8 2048 0 0 8192 0 0 4 0 2 8224 0 0 4096 0 0 64 0 16386 2048 512 5120 32768 4160 512 0 0 512 0 0 0 8 0 0 0 0 0 0 0 8320 0 0 64 16384 16 0 0 0 4 128 8192 1024 0 2048...
output:
113134088 271310664 142021959 771434593 462641801 447067166 870052188 985866201 925618887 81764332 143783792 621593236 863707267 834046424 450353991 858184227 79201855 721850044 757424758 42085201 806870006 528044310 815006195 283966654 133805243 883587876 917828483 930878846 982582330 952003871 392...
result:
ok 65536 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
2 2 2 400000000 600000000 1 0 2 1
output:
0 200000002 680000005 120000001
result:
ok 4 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
10 5 5 30917 23628 20402 8259 999916794 23 25 18 0 26 13 11 0 7 7 7 10 0 12 30 9 6 17 0 18 26 0 27 20 14 24 29 0 26 0 10 23 0 8 7 7 21 8 0 17 2 30 21 0 30 29 10 0 27 30
output:
28922508 0 35621404 0 0 0 888248407 987509770 49397963 679795862 955143439 848384330 218304519 79967140 395924634 114547821 0 895939031 439920966 216672282 170089344 877936956 565519965 184330350 210465780 167531170 720441818 841868009 666011595 327987524 706054720 727462785
result:
ok 32 lines
Test #5:
score: 0
Accepted
time: 885ms
memory: 140328kb
input:
100 16 8 31365 21599 10193 28133 28700 27407 14496 999838107 4022 50386 30744 39278 43773 0 18674 38369 0 33802 31067 14537 43121 61045 29756 8818 5508 61053 28374 0 10443 64627 15285 6833 15374 28108 52460 1325 0 6241 10022 23568 0 42995 8213 895 38219 18427 692 21001 62860 2351 62552 51883 48859 0...
output:
452309043 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:
ok 65536 lines