QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#218668 | #6555. Sets May Be Good | lmeowdn | WA | 252ms | 9552kb | C++14 | 2.8kb | 2023-10-18 16:40:55 | 2023-10-18 16:40:55 |
Judging History
answer
//vanitas vanitatum et omnia vanitas
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
return x*w;
}
const int N=1005,mod=998244353;
int n,m,p[N],ans;
bool e[N][N];
void solve(vi &s,int pp) {
/*
cout<<"SOLVE: ("<<pp<<") ";
sort(s.begin(),s.end());
for(int x:s) cout<<x<<" "; puts("");
for(int x:s) {
for(int y:s) cout<<e[x][y];
puts("");
}
*/
if(s.size()==0) {ans=(ans+pp*(!e[0][0]))%mod; return;}
else if(s.size()==1) {
if(e[0][0]) return;
e[0][s[0]]^=e[s[0]][s[0]];
ans=(ans+pp*(1+(!e[0][s[0]])))%mod;
return;
}
for(int x:s) if(e[x][x]) e[0][x]^=1, e[x][0]^=1, e[x][x]=0;
int u=s[0], v=0, n=s.size();
for(int x:s) if(e[u][x]) {v=x; break;}
if(!v) {
if(e[0][u]) {ans=(ans+p[n-1]*pp)%mod; return;}
vi t; for(int x:s) if(x!=u) t.eb(x);
solve(t,pp*2%mod); return;
}
ans=(ans+p[n-2]*pp)%mod; //cout<<p[n-2]*pp<<endl;
static int a[N],b[N]; s.eb(0);
for(int x:s) a[x]=e[u][x], b[x]=e[v][x];
vi t; for(int x:s) if(x!=u&&x!=v) t.eb(x);
for(int x:t) for(int y:t) if(x<=y) {
//if(x!=u&&x!=v&&y!=u&&y!=v) cout<<x<<" "<<y<<" "<<a[x]<<" "<<b[y]<<endl;
if(x==y) e[x][y]^=(a[x]&&b[x]);
else {
if(a[x]&&b[y]) e[x][y]^=1, e[y][x]^=1;
if(b[x]&&a[y]) e[x][y]^=1, e[y][x]^=1;
}
} t.pop_back();
solve(t,pp*2%mod);
}
signed main() {
n=read(), m=read();
p[0]=1; rep(i,1,n) p[i]=p[i-1]*2%mod;
rep(i,1,m) {
int u=read(), v=read();
//if(u>v)swap(u,v);
e[u][v]^=1, e[v][u]^=1;
}
vi g; rep(i,1,n) g.eb(i);
solve(g,1); printf("%lld\n",ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
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: 3804kb
input:
3 0
output:
8
result:
ok 1 number(s): "8"
Test #3:
score: 0
Accepted
time: 0ms
memory: 4080kb
input:
2 1 1 2
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: 0
Accepted
time: 0ms
memory: 4012kb
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: 4000kb
input:
1 0
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3736kb
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: 3716kb
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: 3996kb
input:
5 0
output:
32
result:
ok 1 number(s): "32"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3676kb
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: 3808kb
input:
6 0
output:
64
result:
ok 1 number(s): "64"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3808kb
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: 3808kb
input:
7 0
output:
128
result:
ok 1 number(s): "128"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3984kb
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: 3828kb
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: 0
Accepted
time: 252ms
memory: 7520kb
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:
818794637
result:
ok 1 number(s): "818794637"
Test #16:
score: 0
Accepted
time: 152ms
memory: 7388kb
input:
1000 10000 1 14 1 53 1 132 1 139 1 174 1 237 1 246 1 278 1 302 1 349 1 353 1 396 1 465 1 652 1 698 1 706 1 753 1 845 1 848 1 862 1 884 1 911 1 1000 2 31 2 57 2 80 2 118 2 182 2 195 2 198 2 344 2 347 2 585 2 591 2 597 2 611 2 623 2 642 2 672 2 694 2 704 2 731 2 770 2 852 2 923 2 974 3 8 3 12 3 59 3 8...
output:
128609606
result:
ok 1 number(s): "128609606"
Test #17:
score: 0
Accepted
time: 104ms
memory: 7912kb
input:
1000 1000 1 179 1 188 1 421 3 14 3 676 4 386 4 740 4 797 6 164 6 374 7 161 8 34 8 359 8 402 9 188 9 452 9 708 10 278 10 425 10 758 11 242 12 338 12 402 12 875 13 22 13 313 13 340 13 711 14 624 14 729 14 857 15 493 15 611 16 540 17 628 17 745 18 598 18 844 19 453 20 147 20 527 21 62 21 313 22 560 22 ...
output:
890151081
result:
ok 1 number(s): "890151081"
Test #18:
score: 0
Accepted
time: 31ms
memory: 9552kb
input:
1000 100 7 816 19 226 20 568 24 530 26 137 33 640 61 149 67 521 77 701 79 976 80 313 84 958 84 991 85 555 95 428 107 181 108 800 110 898 120 481 136 737 147 275 148 970 153 919 163 326 177 842 178 257 189 808 195 1000 200 580 204 509 207 746 211 419 216 387 219 534 225 796 232 633 238 769 248 997 25...
output:
57698280
result:
ok 1 number(s): "57698280"
Test #19:
score: 0
Accepted
time: 166ms
memory: 7388kb
input:
1000 100000 1 2 1 27 1 34 1 41 1 53 1 60 1 66 1 81 1 82 1 84 1 88 1 93 1 97 1 100 1 101 1 107 1 111 1 112 1 119 1 126 1 127 1 128 1 132 1 133 1 134 1 139 1 153 1 155 1 177 1 182 1 185 1 187 1 192 1 197 1 214 1 215 1 217 1 221 1 227 1 230 1 231 1 232 1 235 1 240 1 243 1 246 1 247 1 248 1 254 1 258 1 ...
output:
818794637
result:
ok 1 number(s): "818794637"
Test #20:
score: -100
Wrong Answer
time: 169ms
memory: 7428kb
input:
1000 200000 1 3 1 4 1 7 1 11 1 14 1 15 1 18 1 21 1 23 1 25 1 26 1 27 1 28 1 29 1 32 1 33 1 38 1 40 1 41 1 43 1 44 1 46 1 48 1 49 1 50 1 51 1 52 1 53 1 56 1 57 1 60 1 61 1 62 1 65 1 69 1 72 1 74 1 77 1 83 1 86 1 87 1 89 1 96 1 97 1 100 1 103 1 104 1 105 1 106 1 108 1 111 1 113 1 115 1 119 1 122 1 125...
output:
892861024
result:
wrong answer 1st numbers differ - expected: '510735315', found: '892861024'