QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#422473 | #7303. City United | dayux | WA | 20ms | 168896kb | C++14 | 1.5kb | 2024-05-27 14:52:07 | 2024-05-27 14:52:08 |
Judging History
answer
#include <bits/stdc++.h>
const int maxn = 50, maxd = 13, mod = 4;
std::array<int, maxn + 1> e;
std::array<std::array<std::array<short, 1 << maxd>, 1 << maxd>, 2> f;
void inc(short &x, short y) {
if ((x += y) >= mod) {
x -= mod;
}
}
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int n, m;
std::cin >> n >> m;
for (int i = 0; i < m; ++i) {
int u, v;
std::cin >> u >> v;
e[std::max(u, v)] |= 1 << (std::abs(u - v) - 1);
}
f[0 & 1][0][0] = 1;
int all = (1 << maxd) - 1;
for (int i = 1; i <= n; ++i) {
for (int S = 0; S <= all; ++S) {
for (int T = S; ; T = (T - 1) & S) {
f[i & 1][S][T] = 0;
if (T == 0) {
break;
}
}
}
for (int S = 0; S <= all; ++S) {
for (int T = S; ; T = (T - 1) & S) {
if (f[(i - 1) & 1][S][T] != 0) {
inc(f[i & 1][(S << 1) & all][(T << 1) & all], f[(i - 1) & 1][S][T]);
if ((e[i] & (S ^ T)) == 0) {
inc(f[i & 1][(S << 1 | 1) & all][(T << 1) & all], f[(i - 1) & 1][S][T]);
}
if ((e[i] & T) == 0) {
inc(f[i & 1][(S << 1 | 1) & all][(T << 1 | 1) & all], f[(i - 1) & 1][S][T]);
}
}
if (T == 0) {
break;
}
}
}
}
short ans = 0;
for (int S = 0; S <= all; ++S) {
for (int T = S; ; T = (T - 1) & S) {
inc(ans, f[n & 1][S][T]);
if (T == 0) {
break;
}
}
}
std::cout << ans / 2 << "\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 20ms
memory: 168896kb
input:
3 2 1 2 2 3
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: -100
Wrong Answer
time: 20ms
memory: 166760kb
input:
3 3 1 2 2 3 3 1
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'