QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#582583 | #7925. Chayas | qwerasdf | WA | 0ms | 7704kb | C++20 | 1.5kb | 2024-09-22 16:53:20 | 2024-09-22 16:53:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 119<<23|1;
long long final_dp[1<<24];
long long possible_after[1<<24];
long long complement_after[1<<24];
long long ALL_MASK;
int n, m;
int a, b, c;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
ALL_MASK = (1 << n) - 1;
for (int i = 0; i <= ALL_MASK; ++i) {
possible_after[i] = ALL_MASK;
complement_after[i] = ALL_MASK;
}
for (int i = 0; i < m; ++i) {
cin >> a >> b >> c;
--a; --b; --c;
long long set_mask = (1 << a) | (1 << c);
long long possible_mask = ALL_MASK ^ (1 << b);
possible_after[set_mask] &= possible_mask;
complement_after[set_mask] &= possible_mask;
}
for (int i = 0; i < n; ++i) {
for (int mask = 0; mask < (1 << n); ++mask) {
if (mask & (1 << i)) {
possible_after[mask] |= possible_after[mask ^ (1 << i)];
complement_after[mask] |= complement_after[mask ^ (1 << i)];
}
}
}
final_dp[0] = 1;
for (int mask = 0; mask < (1 << n); ++mask) {
for (int i = 0; i < n; ++i) {
if ((mask & (1 << i)) && (possible_after[mask ^ (1 << i)] & (1 << i)) && (complement_after[ALL_MASK ^ mask] & (1 << i))) {
final_dp[mask] = final_dp[mask] + final_dp[mask ^ (1 << i)] % MOD;
}
}
}
cout << final_dp[ALL_MASK];
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 7704kb
input:
5 4 1 2 4 2 3 5 3 2 4 1 3 2
output:
120
result:
wrong answer 1st lines differ - expected: '4', found: '120'