QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#218272#6555. Sets May Be GoodzhaohaikunWA 0ms3708kbC++142.6kb2023-10-17 22:08:282023-10-17 22:08:28

Judging History

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

  • [2023-10-17 22:08:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3708kb
  • [2023-10-17 22:08:28]
  • 提交

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) {
		// F(x, 1, i) {
		// 	F(y, 1, i)
		// 		cout << a[x][y];
		// 	cout << endl;
		// }
		// cout << endl;
		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();
			// F(x, 1, i) {
			// 	F(y, 1, i)
			// 		cout << a[x][y];
			// 	cout << endl;
			// }
			// cout << endl;
			// debug << pos << endl;
			a[i][pos] = false;
			F(j, 1, i - 1) if (j != pos && a[pos][j]) {
				a[j] ^= a[i];
				if (a[i][i] ^ a[i][j]) a[j][j].flip();
			}
			F(j, 1, i - 1) if (j != pos && a[i][j]) {
				a[j] ^= a[pos];
			}
			if (a[pos][pos]) {
				F(j, 1, n)
					if (j != i && j != pos && a[i][j]) a[j][j].flip();
				if (a[i][i]) ans = (ll) ans * (MOD - 1) % MOD;//, debug << "FUCK\n";
			}
			// F(x, 1, i) {
			// 	F(y, 1, i)
			// 		cout << a[x][y];
			// 	cout << endl;
			// }
			// cout << pos << endl;
			// debug << i << " " << pos << endl;
			F(j, 1, i - 2) {
				if (j >= pos) a[j] = a[j + 1];
				bitset <N> s = (a[j] >> pos) << pos;
				// F(k, 1, i - 1) cout << a[j][k]; cout << endl;
				a[j] = a[j] ^ s ^ (s >> 1);
				// F(k, 1, i - 2) cout << a[j][k]; cout << endl;
			}
			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?
4 6
1 2
1 3
1 4
2 3
2 4
3 4
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3580kb

input:

3 0

output:

8

result:

ok 1 number(s): "8"

Test #3:

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

input:

2 1
1 2

output:

3

result:

ok 1 number(s): "3"

Test #4:

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

input:

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

output:

6

result:

ok 1 number(s): "6"

Test #5:

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

input:

1 0

output:

2

result:

ok 1 number(s): "2"

Test #6:

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

input:

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

output:

8

result:

ok 1 number(s): "8"

Test #7:

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

input:

5 3
1 3
1 4
1 5

output:

24

result:

ok 1 number(s): "24"

Test #8:

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

input:

5 0

output:

32

result:

ok 1 number(s): "32"

Test #9:

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

input:

6 3
1 2
3 4
3 6

output:

40

result:

ok 1 number(s): "40"

Test #10:

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

input:

6 0

output:

64

result:

ok 1 number(s): "64"

Test #11:

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

input:

7 3
2 3
3 6
6 7

output:

80

result:

ok 1 number(s): "80"

Test #12:

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

input:

7 0

output:

128

result:

ok 1 number(s): "128"

Test #13:

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

input:

20 30
1 7
1 9
1 12
1 13
2 6
2 17
3 13
4 12
4 15
4 17
6 10
6 17
7 8
7 18
8 14
9 13
10 16
10 17
12 14
13 15
13 16
13 20
14 16
14 18
14 20
15 17
15 18
15 19
15 20
16 17

output:

525312

result:

wrong answer 1st numbers differ - expected: '524288', found: '525312'