QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#574651 | #7925. Chayas | sea_bird | WA | 0ms | 3620kb | C++20 | 1.6kb | 2024-09-18 23:33:58 | 2024-09-18 23:34:07 |
Judging History
answer
#include<bits/stdc++.h>
typedef long long ll;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
const ll mod = 998244353;
ll f[1 << 24];
bool g[25][25][25];
bool fg[25][25];
int cnt = 0;
pii arr[10100];
int np[25][25];
void solve() {
int n, m;
std::cin >> n >> m;
for (int i = 1; i <= m; i++) {
int a, b, c;
std::cin >> a >> b >> c;
g[a][b][c] = true;
g[c][b][a] = true;
}
for (int a = 1; a <= n; a++) {
for (int b = 1; b <= n; b++) {
for (int c = 1; c <= n; c++) {
if (g[c][a][b] or g[c][b][a]) {
np[a][b] |= (1 << (c - 1));
}
}
}
}
for(int a = 1;a <= n;a++){
for(int b = a;b <= n;b++){
np[a][b] |= np[b][a];
}
}
f[0] = 1;
for (int p = 0; p < (1 << n); p++) {
int x = 0;
for (int a = 1; a <= n; a++) {
if(!(p & (1 << (a - 1))))
continue;
for (int b = a; b <= n; b++) {
if ((!(p & (1 << (b - 1))))) {
x |= np[a][b];
}
}
}
for (int c = 1; c <= n; c++) {
if (p & (1 << (c - 1)))
continue;
if (!(x & (1 << (c - 1)))) {
f[p | (1 << (c - 1))] = (f[p | (1 << (c - 1))] + f[p]) % mod;
}
}
}
std::cout << f[(1 << n) - 1] << "\n";
}
int main() {
std::ios::sync_with_stdio(0);
std::cin.tie(0), std::cout.tie(0);
int t = 1;
while (t--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3620kb
input:
5 4 1 2 4 2 3 5 3 2 4 1 3 2
output:
30
result:
wrong answer 1st lines differ - expected: '4', found: '30'