QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#218215#6555. Sets May Be GoodzhaohaikunWA 0ms3552kbC++141.7kb2023-10-17 20:40:442023-10-17 20:40:44

Judging History

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

  • [2023-10-17 20:40:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2023-10-17 20:40:44]
  • 提交

answer

// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "[" << __LINE__ << "] "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T& x, T y) { x = max(x, y); }
template <typename T> inline void chkmin(T& x, T y) { x = min(x, y); }
template <typename T> inline void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
const int N = 1010, MOD = 998244353, inv2 = (MOD + 1) >> 1;
int n, m, ans = 1, t = 1;
bitset <N> a[N];
signed main() {
	read(n), read(m);
	F(i, 1, n) t = 2 * t % MOD;
	F(i, 1, m) {
		int x, y; read(x), read(y);
		a[x][y] = a[y][x] = true;
	}
	DF(i, n, 1) {
		bool flag = false;
		F(j, 1, i - 1) flag |= a[i][j];
		if (flag) {
			int pos;
			F(j, 1, i - 1)
				if (a[j][i]) {
					pos = j;
					break;
				}
			F(j, 1, i - 1)
				if (a[i][i] && a[i][j] && j != pos) a[j][j].flip();
			a[i][pos] = false;
			F(j, 1, i - 1) a[j] ^= a[i];
			F(j, 1, i - 2) {
				if (j >= pos) a[j] = a[j + 1];
				bitset <N> s = (a[j] >> (pos + 1)) << (pos + 1);
				a[j] = a[j] ^ s ^ (s >> 1);
			}
			i--;
			ans = (ll) ans * 2 % MOD;
			// debug << i << endl;
		} else if (!a[i][i]) ans = (ll) ans * 2 % MOD;//, debug << i << endl;
			else ans = 0;
	}
	// debug << ans << endl;
	cout << (ll) (t + ans) * inv2 % MOD;
	return 0;
}
/* why?
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3492kb

input:

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

output:

16

result:

ok 1 number(s): "16"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3368kb

input:

3 0

output:

8

result:

ok 1 number(s): "8"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

2 1
1 2

output:

3

result:

ok 1 number(s): "3"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3492kb

input:

4 6
1 2
1 3
1 4
2 3
2 4
3 4

output:

10

result:

wrong answer 1st numbers differ - expected: '6', found: '10'