QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#218839#6555. Sets May Be GoodzhouhuanyiWA 0ms3580kbC++141.4kb2023-10-18 19:13:552023-10-18 19:13:55

Judging History

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

  • [2023-10-18 19:13:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3580kb
  • [2023-10-18 19:13:55]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<bitset>
#define N 1001
#define mod 998244353
using namespace std;
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
int MD(int x)
{
	return x>=mod?x-mod:x;
}
int MD2(int x)
{
	return x<0?x+mod:x;
}
int n,m,inv2=(mod+1)>>1,F[N+1],res=1,ans=1;
bitset<N+1>B[N+1];
bool used[N+1];
int main()
{
	int x,y;
	n=read(),m=read();
	for (int i=1;i<=n;++i) F[i]=1,res=2ll*res%mod;
	for (int i=1;i<=m;++i)
	{
		x=read(),y=read();
		if (x>y) swap(x,y);
		B[x][y]=B[y][x]=1;
	}
	for (int i=1;i<=n;++i)
		for (int j=i+1;j<=n;++j)
			if (!used[i]&&!used[j])
			{
				used[i]=used[j]=1,ans=2ll*ans%mod;
				if (B[i][i])
				{
					for (int t=1;t<=n;++t)
						if (B[j][t])
							B[t][t]=B[t][t]^1;
				}
				if (B[j][j])
				{
					for (int t=1;t<=n;++t)
						if (B[i][t])
							B[t][t]=B[t][t]^1;
				}
				if (B[i][i]&&B[j][j]) ans=MD2(-ans);
				for (int k=1;k<=n;++k)
					if (!used[k])
						for (int t=1;t<=n;++t)
							if (!used[t]&&B[i][k]&&B[j][t])
							{
								B[k][t]=B[k][t]^1;
								if (k!=t) B[t][k]=B[t][k]^1;
							}
				break;
			}
	for (int i=1;i<=n;++i)
		if (!used[i])
		{
			if (!B[i][i]) ans=2ll*ans%mod;
			else ans=0;
		}
	printf("%lld\n",1ll*(res+ans)*inv2%mod);
	return 0;
}

詳細信息

Test #1:

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

input:

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

output:

16

result:

ok 1 number(s): "16"

Test #2:

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

input:

3 0

output:

6

result:

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