QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#218846 | #6555. Sets May Be Good | zhouhuanyi | WA | 0ms | 3896kb | C++14 | 1.4kb | 2023-10-18 19:15:58 | 2023-10-18 19:15:58 |
Judging History
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]&&B[i][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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3740kb
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: 3800kb
input:
3 0
output:
8
result:
ok 1 number(s): "8"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
2 1 1 2
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3812kb
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'