QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#354741#6555. Sets May Be GoodyyyyxhWA 0ms3600kbC++141.5kb2024-03-15 22:18:562024-03-15 22:18:57

Judging History

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

  • [2024-03-15 22:18:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-03-15 22:18:56]
  • 提交

answer

#include <cstdio>
#include <bitset>
#define for_bset(i,j) \
	for(int j=f[i]._Find_first();j!=N;j=f[i]._Find_next(j))
using namespace std;
int n,m;
int read(){
	char c=getchar();int x=0;
	while(c<48||c>57) c=getchar();
	do x=(x<<1)+(x<<3)+(c^48),c=getchar();
	while(c>=48&&c<=57);
	return x;
}
const int N=1000,P=998244353;
bitset<N> f[N],del;
int res,pw[N+1];
inline void inc(int &x,int v){(x+=v)>=P&&(x-=P);}
int main(){
	n=read();m=read();
	for(int i=0;i<m;++i){
		int u=read()-1,v=read()-1;
		f[u].set(v);f[v].set(u);
	}
	pw[0]=1;
	for(int i=1;i<=n;++i) (pw[i]=(pw[i-1]<<1))>=P&&(pw[i]-=P);
	bool par=0;int cc=0,cur=n;
	for(int i=0;i<n;++i){
		if(del[i]) continue;
		del.set(i);--cur;
		int sz=0,pos=-1;
		bool tag=0,rev=f[i][i];
		f[i].reset(i);
		for_bset(i,j){
			f[j].reset(i);f[i].reset(j);
			if(sz++){
				if(tag) f[j].flip(j);
				f[j]^=f[pos];
			}
			else{
				tag=f[j][j];f[j].reset(j);pos=j;
				del.set(j);--cur;
				if(rev&&tag) par^=1;
				for_bset(j,k){
					f[k].reset(j);
					if(rev) f[k].flip(k);
					f[k]^=f[i];
					if(f[i][k]) f[k].flip(k);
				}
			}
		}
		if(sz) inc(res,pw[cur+cc]),f[pos].reset();
		else{
			if(rev){
				inc(res,pw[cur+cc]);
				return 0;
			}
		}
		++cc;
		/*
		 * for(int x=0;x<n;++x) if(!del[x]){
		 *     for(int y=0;y<n;++y) if(!del[y]){
		 *         if(f[x][y]) putchar('1');
		 *         else putchar('0');
		 *     }
		 *     putchar('\n');
		 * }
		 */
	}
	if(!par) inc(res,pw[cc]);
	printf("%d\n",res);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3600kb

input:

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

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements