QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#101715#6344. The Best Problem of 2021CrysflyWA 3ms7256kbC++172.9kb2023-04-30 21:53:272023-04-30 21:53:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-30 21:53:30]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:7256kb
  • [2023-04-30 21:53:27]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

#define mod 998244353
struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,int b){return a.x==b;}
	friend bool operator !=(modint a,int b){return a.x!=b;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 200005
#define inf 0x3f3f3f3f

struct basis{
	int a[5];
	basis(){memset(a,0,sizeof a);}
	bool ins(int x){
		Rep(i,4,0){
			if(!(x>>i&1))continue;
			if(a[i]){x^=a[i];continue;}
			a[i]=x;
			For(j,0,i-1)if(a[j]&&(a[i]>>j&1))a[i]^=a[j];
			For(j,i+1,4)if(a[j]&&(a[j]>>i&1))a[j]^=a[i];
			return 1;
		}return 0;
	}
	bool chk(int x){
		Rep(i,4,0) x=min(x,x^a[i]);
		return !x;
	}
	inline int hsh(){return a[0]|a[1]<<1|a[2]<<3|a[3]<<6|a[4]<<10;}
}t[maxn],_empty;

int id[maxn],cnt;
void dfs(basis u){
	int x=u.hsh();
	if(id[x])return;
	id[x]=++cnt,t[cnt]=u;
	For(i,1,15){
		basis v=u;
		if(v.ins(i))dfs(v);
	}
}

int x=8+4+1;

signed main()
{
	dfs(_empty);
	modint res=0;
	For(i,1,cnt){
		modint pw=1;
		int rk=0;
		For(j,0,4)rk+=(t[i].a[j]>0); 
		For(j,1,x)if(t[i].chk(j))pw*=2;
		rk=4-rk;
		modint coef=sign(rk)*qpow(2,rk*(rk-1)/2);
		res+=coef*pw;
	}
	cout<<res.x;
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 7220kb

input:

4 4
0001
0010
0100
1000
1101

output:

7364

result:

ok 1 number(s): "7364"

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 7256kb

input:

3 2
00
00
00
11

output:

7364

result:

wrong answer 1st numbers differ - expected: '0', found: '7364'