QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#359037#6555. Sets May Be GoodKevin5307WA 1ms3672kbC++201.8kb2024-03-20 11:18:332024-03-20 11:18:34

Judging History

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

  • [2024-03-20 11:18:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3672kb
  • [2024-03-20 11:18:33]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
const int mod=998244353;
int G[1010][1010];
int dp[1010][2][2];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		if(u>v) swap(u,v);
		G[u][v]^=1;
	}
	for(int i=n-1;i>=1;i--)
	{
		if(!G[i][i+1])
			for(int j=1;j<i;j++)
				if(G[j][i+1])
				{
					for(int x=1;x<j;x++)
						swap(G[x][j],G[x][i]);
					for(int x=i+1;x<=n;x++)
						swap(G[i][x],G[j][x]);
					swap(G[i][i],G[j][j]);
					for(int x=j+1;x<i;x++)
						swap(G[j][x],G[x][i]);
					break;
				}
		for(int j=n;j>=i+2;j--)
			if(G[i][j])
			{
				for(int x=1;x<i;x++)
					G[x][i]^=G[x][j-1];
				G[i][i]^=G[i][j-1];
				for(int x=i+1;x<j-1;x++)
					G[i][x]^=G[x][j-1];
				for(int x=j;x<=n;x++)
					G[i][x]^=G[j-1][x];
			}
	}
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)
				for(int x=0;x<2;x++)
				{
					int nxt=j^(x&G[i][i])^(k&x&G[i-1][i]);
					dp[i][nxt][x]=(dp[i][nxt][x]+dp[i-1][j][k])%mod;
				}
	cout<<(dp[n][0][1]+dp[n][0][0])%mod<<'\n';
	return 0;
}

详细

Test #1:

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

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

input:

3 0

output:

8

result:

ok 1 number(s): "8"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3508kb

input:

2 1
1 2

output:

3

result:

ok 1 number(s): "3"

Test #4:

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

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'