QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#359035 | #6555. Sets May Be Good | Kevin5307 | WA | 1ms | 3708kb | C++20 | 1.8kb | 2024-03-20 11:17:42 | 2024-03-20 11:17:42 |
Judging History
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]^G[j-1][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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3664kb
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: 3708kb
input:
3 0
output:
8
result:
ok 1 number(s): "8"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
2 1 1 2
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3576kb
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: 3504kb
input:
1 0
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3516kb
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: 3688kb
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: 3604kb
input:
5 0
output:
32
result:
ok 1 number(s): "32"
Test #9:
score: 0
Accepted
time: 1ms
memory: 3588kb
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: 3624kb
input:
6 0
output:
64
result:
ok 1 number(s): "64"
Test #11:
score: 0
Accepted
time: 1ms
memory: 3632kb
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: 3552kb
input:
7 0
output:
128
result:
ok 1 number(s): "128"
Test #13:
score: 0
Accepted
time: 1ms
memory: 3684kb
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:
524288
result:
ok 1 number(s): "524288"
Test #14:
score: -100
Wrong Answer
time: 0ms
memory: 3680kb
input:
20 73 1 4 1 9 1 13 2 6 2 7 2 12 2 14 2 18 2 19 3 6 3 10 3 12 3 14 3 16 3 17 3 18 4 6 4 7 4 11 4 14 4 15 4 18 4 19 5 6 5 7 5 9 5 10 5 12 5 14 5 15 5 17 5 18 5 19 5 20 6 12 6 13 6 15 6 16 6 17 7 9 7 16 7 19 8 11 8 15 8 16 8 20 9 10 9 12 9 17 9 20 10 11 10 12 10 14 10 16 10 17 10 18 11 12 11 20 12 13 1...
output:
522240
result:
wrong answer 1st numbers differ - expected: '524288', found: '522240'