The 1st Universal Cup Stage 7: Zaporizhzhia, March 11-12, 2023(Determinant, or...?-子矩阵,det)

Posted nike0good

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了The 1st Universal Cup Stage 7: Zaporizhzhia, March 11-12, 2023(Determinant, or...?-子矩阵,det)相关的知识,希望对你有一定的参考价值。

The 1st Universal Cup
Stage 7: Zaporizhzhia, March 11-12, 2023

Problem K. Determinant, or…?

Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 256 megabytes
You’re given an array a 0 , ⋯   , a 2 n − 1 a_0,\\cdots ,a_2^n-1 a0,,a2n1

Consider a matrix A such that A i j = a i ∣ j A_ij=a_i|j Aij=aij

Find the determinant of A.

Input

The first line of input contains a single integer n( 1 ≤n≤ 20 ).

The second line of input contains 2 n 2^n 2n integers a 0 , ⋯   , a 2 n − 1 ( 0 ≤ a i < 1 0 9 + 9 ) a_0,\\cdots ,a_2^n-1( 0 ≤a_i< 10^9 + 9) a0,,a2n1(0ai<109+9).

Output

Print a single integer, the determinant of A A A modul o 1 0 9 + 9 o 10^9 + 9 o109+9.

考虑这个矩阵刚好可以写成
M = [ A B B B ] M=\\beginbmatrixA & B\\\\B & B\\endbmatrix M=[ABBB]

d e t ( M ) = d e t ( [ A B B B ] ) = d e t ( [ A − B 0 B B ] = d e t ( A − B ) d e t ( B ) det(M)=det(\\beginbmatrixA & B\\\\B & B\\endbmatrix)=det(\\beginbmatrixA-B & 0 \\\\B & B\\endbmatrix=det(A-B)det(B) det(M)=det([ABBB])=det([ABB0B]=det(AB)det(B)
我们发现 A − B A-B AB A A A都满足可以写成 [ A B B B ] \\beginbmatrixA & B\\\\B & B\\endbmatrix [ABBB]这个性质 可以递归下去算

#include<bits/stdc++.h> 
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,0x3f,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define MEMx(a,b) memset(a,b,sizeof(a));
#define INF (0x3f3f3f3f)
#define F (1000000009)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %lld\\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n)  \\
						For(j,m-1) cout<<a[i][j]<<' ';\\
						cout<<a[i][m]<<endl; \\
						 
#pragma comment(linker, "/STACK:102400000,102400000")
#define ALL(x) (x).begin(),(x).end()
#define gmax(a,b) a=max(a,b);
#define gmin(a,b) a=min(a,b);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b)return (a*b)%F;
ll add(ll a,ll b)return (a+b)%F;
ll sub(ll a,ll b)return ((a-b)%F+F)%F;
void upd(ll &a,ll b)a=(a%F+b%F)%F;
inline int read()

	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)) if (ch=='-') f=-1; ch=getchar();
	while(isdigit(ch))  x=x*10+ch-'0'; ch=getchar();
	return x*f;
 
ll f(vi v) 
	int sz=SI(v);
	if(sz==1) return sub(v[0],0);
	
	vi vl,vr;
	Rep(i,sz/2) vl.pb(sub(v[i],v[i+sz/2]));
	Fork(i,sz/2,sz-1) vr.pb(v[i]);
	return (ll)f(vl)*f(vr)%F;

int main()

//	freopen("B.in","r",stdin);
//	freopen(".out","w",stdout);
	int n=read();
	vector<int> a;
	int sz=1<<n;
	Rep(i,sz) a.pb(read());
	cout<<f(a);
	
	
	return 0;


以上是关于The 1st Universal Cup Stage 7: Zaporizhzhia, March 11-12, 2023(Determinant, or...?-子矩阵,det)的主要内容,如果未能解决你的问题,请参考以下文章

HDU 5999: The Third Cup is Free

Reference Collapsing Rules, Universal Reference and the implementation of std::forward() and std::mo

life|October the 1st| five twenty|three–fifths|1970s|30s

World Cup(The 2016 ACM-ICPC Asia China-Final Contest dfs搜索)

The 1st Challenge on Remote Physiological Signal Sensing (RePSS) CVPR2020人脸心率估计竞赛

codeforces Looksery Cup 2015 H Degenerate Matrix