QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#306694#7759. Permutation Counting 2sigma425Compile Error//C++201.5kb2024-01-17 01:54:382024-01-17 01:54:39

Judging History

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

  • [2024-01-17 01:54:39]
  • 评测
  • [2024-01-17 01:54:38]
  • 提交

answer

// #pragma GCC target("avx2,avx512f,avx512vl,avx512bw,avx512dq,avx512cd,avx512vbmi,avx512vbmi2,avx512vpopcntdq,avx512bitalg,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("Ofast")

#include "template.hpp"
#include "math/mint0.cpp"

// https://qoj.ac/contest/1415/problem/7759


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N; cin >> N >> mod;
	// int N; cin >> N; mod = TEN(9)+7;
	InitFact(1100);
	VV<mint> g(N+1,V<mint>(N+1));
	rep1(b,N){
		V<mint> fb(N+1); rep1(i,N) fb[i] = Choose(b-1+i,i);
		// g[a][b] = [x^N]fb^a
		{	// slow
			V<mint> dp = fb;
			rep1(a,N){
				g[a][b] = dp[N];
				per1(j,N) if(dp[j]){
					rep1(i,N-j) dp[j+i] += dp[j] * fb[i];
					dp[j] = 0;
				}
			}
		}
	}
	// g[a][b]: a block * b (possibly empty) block
	rep1(a,N){
		V<mint> f(N+1);
		rep1(k,N){
			rep1(i,k) f[k] += g[a][i] * Choose(k,i) * ((k-i)&1 ? -1 : 1);
		}
		g[a] = f;
	}
	// rep1(i,N){
	// 	rep1(j,N) cout << g[i][j] << " ";
	// 	cout << endl;
	// }

	{
		VV<mint> f(N,V<mint>(N));
		rep(i,N) rep(j,N) f[i][j] = g[i+1][j+1];
		g = f;
	}
	rep(_,2){
		rep(a,N){
			V<mint> alpha(N);
			rep(i,N) alpha[i] = g[a][i] / Choose(N-1,i);
			V<mint> beta(N);
			rep(k,N){
				rep(i,k+1) beta[k] += alpha[i] * Choose(k,i) * ((k-i)&1 ? -1 : 1);
			}
			rep(b,N) g[a][b] = beta[b] * Choose(N-1,b);
		}
		rep(i,N) rep(j,i) swap(g[i][j],g[j][i]);
	}
	rep(i,N){
		rep(j,N) cout << g[i][j] << " ";
		cout << endl;
	}

}

详细

answer.code:4:10: fatal error: template.hpp: No such file or directory
    4 | #include "template.hpp"
      |          ^~~~~~~~~~~~~~
compilation terminated.