QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#216907 | #6555. Sets May Be Good | 275307894a | WA | 192ms | 7972kb | C++14 | 1.4kb | 2023-10-16 08:03:41 | 2023-10-16 08:03:41 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__uint128_t;
const int N=1e3+5,M=N*100+5,K=600+5,mod=998244353,Mod=mod-1;const db eps=1e-6;const int INF=1e9+7;mt19937 rnd(263082);
int n,m,A[N][N],del[N];
ll calc(){
ll ans=1;int i,j,h;
for(i=1;i<=n;i++)if(!del[i]){
ans=ans*2%mod;
int p=0;for(j=i+1;j<=n;j++) if(A[i][j]) {p=j;break;}
if(!p){
if(A[i][i]) return 0;continue;
}
del[p]=1;
for(j=i+1;j<p;j++) if(A[j][p]) for(h=p;h<=n;h++) A[j][h]^=A[i][h];
for(j=p+1;j<=n;j++) if(A[p][j]) for(h=p+1;h<=n;h++) A[min(h,j)][max(h,j)]^=A[i][h];
if(A[i][i]){
if(A[p][p]){
ans=mod-ans;
for(j=p+1;j<=n;j++) A[j][j]^=A[p][j];
}
for(j=p+1;j<=n;j++) A[j][j]^=A[i][j]^A[p][j];
}
}
return ans;
}
void Solve(){
int i,j;scanf("%d%d",&n,&m);
while(m--){
int x,y;scanf("%d%d",&x,&y);A[min(x,y)][max(x,y)]=1;
}
ll tot=1;for(i=1;i<=n;i++) tot=tot*2%mod;
printf("%lld\n",(tot+calc())%mod*(mod+1)/2%mod);
}
int main(){
int t=1;
// scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4048kb
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: 3972kb
input:
3 0
output:
8
result:
ok 1 number(s): "8"
Test #3:
score: 0
Accepted
time: 0ms
memory: 4036kb
input:
2 1 1 2
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: 0
Accepted
time: 0ms
memory: 4044kb
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: 4020kb
input:
1 0
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: 0
Accepted
time: 0ms
memory: 4044kb
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: 3988kb
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: 4040kb
input:
5 0
output:
32
result:
ok 1 number(s): "32"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3984kb
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: 4032kb
input:
6 0
output:
64
result:
ok 1 number(s): "64"
Test #11:
score: 0
Accepted
time: 0ms
memory: 4064kb
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: 4020kb
input:
7 0
output:
128
result:
ok 1 number(s): "128"
Test #13:
score: 0
Accepted
time: 0ms
memory: 4112kb
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: 0
Accepted
time: 0ms
memory: 4080kb
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:
524288
result:
ok 1 number(s): "524288"
Test #15:
score: -100
Wrong Answer
time: 192ms
memory: 7972kb
input:
1000 499500 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1...
output:
202675993
result:
wrong answer 1st numbers differ - expected: '818794637', found: '202675993'