QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#316683#4907. djq 学生物Crysfly15 391ms12280kbC++174.5kb2024-01-28 02:01:032024-01-28 02:01:05

Judging History

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

  • [2024-01-28 02:01:05]
  • 评测
  • 测评结果:15
  • 用时:391ms
  • 内存:12280kb
  • [2024-01-28 02:01:03]
  • 提交

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#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)
#define ll long long
//#define int long long
#define ull unsigned long long
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,modint b){return a.x==b.x;}
	friend bool operator !=(modint a,modint b){return a.x!=b.x;}
	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 2000005
#define inf 0x3f3f3f3f

modint trs[6][6]={
{1,0,0,1,     1,1},// I,inv(p),1
{1,0,-1,-1,  -1,1},// A
{0,1,1,0,    -1,1},// B
{-1,-1,1,0,   1,1},// AB
{0,1,-1,-1,   1,1},// BA
{-1,-1,0,1,  -1,1} // ABA=BAB
};
modint rev[6][6];

#define N 259
modint g[N][N];
bool inv(modint a[N][N],int n){
	static int pi[N],pj[N];
	For(k,1,n){
		pi[k]=pj[k]=0;
		For(i,k,n)For(j,k,n)if(a[i][j].x){pi[k]=i,pj[k]=j;break;}
		if(!pi[k])return puts("-1bb"),exit(0),0;
		For(i,1,n)swap(a[k][i],a[pi[k]][i]);
		For(i,1,n)swap(a[i][k],a[i][pj[k]]);
		if(!a[k][k].x)return puts("-1aa"),exit(0),0;
		a[k][k]=1/a[k][k];
		For(j,1,n)if(j!=k)a[k][j]*=a[k][k];
		For(i,1,n)if(i!=k)For(j,1,n)if(j!=k)a[i][j]-=a[i][k]*a[k][j];
		For(i,1,n)if(i!=k)a[i][k]=-a[i][k]*a[k][k];
	}
	Rep(k,n,1){
		For(i,1,n)swap(a[pj[k]][i],a[k][i]);
		For(i,1,n)swap(a[i][pi[k]],a[i][k]);
	}
	return 1;
}

int n,m;
modint f[maxn],sumw;

void trans(modint to[6][6]){
	static modint tf[6];
	for(int i=1;i<m;i*=6)
		for(int j=0;j<m;j+=i*6)
			For(k,0,i-1){
				For(p,0,5) For(q,0,5) tf[q]+=f[j+k+i*p]*to[p][q];
				For(p,0,5) f[j+k+i*p]=tf[p],tf[p]=0;
			}
}

void solve(int k,vector<vi>id)
{
	int n=id.size();
	if(!k){
		For(i,0,n-1) For(j,0,n-1) g[i+1][j+1]=(i==j)*(sumw+1)-f[id[i][j]];
		inv(g,n);
		For(i,0,n-1) For(j,0,n-1) f[id[i][j]]=g[i+1][j+1];
		return;
	}
	
	For(i,0,n-1)For(j,0,n-1)id[i][j]*=6;
	vector<vi>id2;
	For(i,0,n-1){
		vi o;
		For(j,0,n-1)o.pb(id[i][j]),o.pb(id[i][j]+1);
		id2.pb(o);
		o.clear();
		For(j,0,n-1)o.pb(id[i][j]+2),o.pb(id[i][j]+3);
		id2.pb(o);
	}
	solve(k-1,id2);
	
	id2=id;
	For(i,0,n-1) For(j,0,n-1) id2[i][j]+=4;
	solve(k-1,id2);
	id2=id;
	For(i,0,n-1) For(j,0,n-1) id2[i][j]+=5;
	solve(k-1,id2);
}

signed main()
{
//	freopen("my.out","w",stdout);
	For(i,0,5) For(j,0,5) if(trs[i][j].x<0) trs[i][j].x+=mod;
	For(i,0,5) For(j,0,5) g[i+1][j+1]=trs[i][j];
	inv(g,6);
	For(i,0,5) For(j,0,5) rev[i][j]=g[i+1][j+1];//cout<<rev[i][j].x<<" \n"[j==5];
	n=read();
	m=1; For(i,1,n)m*=6;
	For(i,0,m-1)f[i]=read(),sumw+=f[i];
	trans(trs);
//	For(i,0,m-1) cout<<f[i].x<<" "; cout<<"fir\n";
	solve(n,{{0}});
//	For(i,0,m-1) cout<<f[i].x<<" "; cout<<"fir\n";
	trans(rev);
	int res=0;
	For(i,0,m-1) res^=f[i].x;
//	For(i,0,m-1) cout<<f[i].x<<" "; cout<<"\n";
	cout<<res;
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 11880kb

input:

1
10 10 10 10 499122217 499122156

output:

-1bb

result:

wrong output format Expected integer, but "-1bb" found

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 15
Accepted

Test #8:

score: 15
Accepted
time: 55ms
memory: 11864kb

input:

7
13237606 0 0 696947386 879320747 0 0 0 0 0 0 0 0 0 0 0 0 0 266959993 0 0 371358373 632390641 0 666960563 0 0 708812199 564325578 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 299649176 0...

output:

101942575

result:

ok 1 number(s): "101942575"

Test #9:

score: 0
Accepted
time: 382ms
memory: 12280kb

input:

8
114962507 0 0 952617546 783387964 0 0 0 0 0 0 0 0 0 0 0 0 0 950188130 0 0 79845349 400660703 0 865722684 0 0 186015033 757001842 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 563538995 0...

output:

976515923

result:

ok 1 number(s): "976515923"

Test #10:

score: 0
Accepted
time: 378ms
memory: 12280kb

input:

8
125443968 0 0 825927837 967844197 0 0 0 0 0 0 0 0 0 0 0 0 0 128726374 0 0 893763697 934490504 0 811156183 0 0 90656766 98645533 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 858436076 0 ...

output:

660528054

result:

ok 1 number(s): "660528054"

Test #11:

score: 0
Accepted
time: 391ms
memory: 12164kb

input:

8
553951831 0 0 3610932 151003694 0 0 0 0 0 0 0 0 0 0 0 0 0 239318443 0 0 408922789 79644945 0 59445445 0 0 144621393 336045244 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 329064496 0 0 ...

output:

355824768

result:

ok 1 number(s): "355824768"

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%