QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#694916 | #9115. Contour Multiplication | icpc_zhzx034 | WA | 0ms | 3640kb | C++14 | 937b | 2024-10-31 18:56:52 | 2024-10-31 18:57:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = (1 << 18);
const int B = 18;
ll n, mod, k, f[N][B];
int main() {
#ifdef LOCAL
assert(freopen("test.in", "r", stdin));
assert(freopen("test.out", "w", stdout));
#endif
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
cin >> n >> mod >> k;
for (int i = 0; i < (1 << n); ++i) {
for (int j = 0; j < n; ++j) {
f[i][j] = 1;
}
}
while (k--) {
int x, y, z;
cin >> x >> y >> z;
f[x][y] = f[x][y] * z % mod;
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < (1 << n); ++j) {
for (int k = 0; k < n - 1; ++k) {
if (!(j & (1 << i))) {
f[j ^ (1 << i)][k] = f[j ^ (1 << i)][k] * f[j][k + 1] % mod;
f[j][k] = f[j][k] * f[j ^ (1 << i)][k + 1] % mod;
}
}
}
}
for (int i = 0; i < (1 << n); ++i) {
cout << f[i][0] << " ";
}
cout << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
3 100 2 0 2 4 3 0 25
output:
1 1 1 0 1 4 4 1
result:
ok 8 tokens
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3640kb
input:
4 998244353 7 0 2 4 3 0 25 9 4 37 4 1 16 6 3 8 1 4 68 13 3 97
output:
1552 8 1 9700 1 64 6208 1 8 4 388 8 64 8 1 1
result:
wrong answer 7th words differ - expected: '229696', found: '6208'