QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#652635 | #9115. Contour Multiplication | gzy | WA | 0ms | 5572kb | C++14 | 707b | 2024-10-18 18:57:22 | 2024-10-18 18:57:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
const int N = 20;
int i, j, k, n, m, c, d, x, mo, q;
int f[2][1 << 20][N], s, u, v = 1;
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> mo >> q; s = 1 << n;
for(j = 0; j < s; j++) for(k = 0; k <= n; k++) f[0][j][k] = 1;
while(q--) {
cin >> c >> d >> x;
f[u][c][d] = 1LL * f[u][c][d] * x % mo;
cout << f[u][c][d] << "\n";
}
for(i = 0; i < n; i++) {
swap(u, v);
for(j = 0; j < s; j++) for(k = 0; k <= n; k++) {
f[u][j][k] = 1LL * f[v][j][k] * f[v][j ^ (1 << i)][k + 1] % mo;
}
}
for(i = 0; i < s; i++) cout << f[u][i][0] << " ";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5572kb
input:
3 100 2 0 2 4 3 0 25
output:
4 25 1 1 1 0 1 4 4 1
result:
wrong answer 1st words differ - expected: '1', found: '4'