QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#269333#7623. Coloring TapeFISHER_WA 1ms6048kbC++142.0kb2023-11-29 15:25:122023-11-29 15:25:13

Judging History

你现在查看的是最新测评结果

  • [2023-11-29 15:25:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6048kb
  • [2023-11-29 15:25:12]
  • 提交

answer

#include <bits/stdc++.h>
#define PB push_back
#define EB emplace_back
using namespace std;
const int mod = 998244353;
inline int Mod(int x) { return x + ((x >> 31) & mod); }
inline int add(int x, int y) { return Mod(x + y - mod); }
inline int sub(int x, int y) { return Mod(x - y); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline void upd(int& x, int y) { x = add(x, y); }
const int maxn = 14, maxm = 500, M = 120000;
struct op { int x, y, df; };
vector<op> L[maxm + 5];
int fr[M], to[M], col[M][maxn + 5];
int p[maxn + 5];
bool vis[maxn + 5];
int f[2][1 << maxn];
inline bool get(int v, int w) { return (v >> w) & 1; }
int main() {
	int n, m, r;
	scanf("%d%d%d", &n, &m, &r);
	for (int i = 1; i <= r; i++) {
		int c, x, y, df;
		scanf("%d%d%d%d", &c, &x, &y, &df);
		if (c == 1 && !df) return puts("0"), 0;
		L[c].PB({x, y, df});
	}
	int S = 1 << n;
	int tc = 0;
	for (int s = 0; s < S; s++) {
		int c = 0;
		for (int i = 0; i < n; i++)
			if (get(s, i)) p[++c] = i;
		for (int s2 = s; s2 < S; s2 = (s2 + 1) | s) {
			memset(vis, 0, sizeof(vis));
			int ns = S - 1;
			for (int i = 0; i < n; i++)
				if (!get(s, i)) {
					int t = i - 1;
					if (get(s2, i)) t += 2;
					if (t < 0 || t >= n || vis[t] || vis[t + 1]) goto ed;
					vis[t] = 1, ns ^= 1 << t;
				}
			fr[++tc] = s, to[tc] = ns;
			for (int i = 1, j = 0; i <= c; i++, j++) {
				while (vis[j]) j++;
				for (int k = p[i]; k <= j; k++) col[tc][k] = i;
			}
			ed:;
		}
	}
	int nw = 0, lt = 1;
	f[nw][S - 1] = 1;
	for (int i = 2; i <= m; i++) {
		swap(nw, lt);
		memset(f[nw], 0, sizeof(f[nw]));
		for (int w = 1; w < S; w <<= 1)
			for (int j = 0; j < S; j += (w << 1))
				for (int k = 0; k < w; k++) upd(f[lt][j + k], f[lt][w + j + k]);
		for (int j = 1; j <= tc; j++) {
			bool flg = 1;
			for (const auto& [x, y, df] : L[i])
				if ((col[j][x - 1] != col[j][y - 1]) != df) { flg = 0; break; }
			if (flg) upd(f[nw][to[j]], f[lt][fr[j]]);
		}
	}
	int ans = 0;
	for (int s = 1; s < S; s++) upd(ans, f[nw][s]);
	printf("%d", ans);
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 6048kb

input:

3 5 3
3 2 3 0
4 1 2 0
5 1 3 0

output:

19

result:

ok 1 number(s): "19"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 4020kb

input:

5 10 10
9 3 4 1
2 4 5 0
7 2 3 0
9 2 3 0
6 3 5 0
6 2 4 1
2 4 5 0
1 1 3 1
7 2 4 0
10 2 3 0

output:

1370

result:

wrong answer 1st numbers differ - expected: '1514', found: '1370'