QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#104359#6333. Festivals in JOI Kingdom 2oscaryangCompile Error//C++201.4kb2023-05-10 14:30:192023-05-10 14:30:22

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-10 14:30:22]
  • 评测
  • [2023-05-10 14:30:19]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=3005;

int n,P,c[N][N];
int o,w,f[2][N][N][3],ans,all;

inline void inc(int &x,int y) { x+=y-P; x+=(x>>31)&P; }
inline void dec(int &x,int y) { x-=y; x+=(x>>31)&P; }
inline int pls(int x,int y) { x+=y-P; x+=(x>>31)&P; return x; }

int main() {
	cin>>n>>P;
	
	for(int i=0;i<N;i++) {
		c[i][0]=1;
		for(int j=1;j<=i;j++) inc(c[i][j]=c[i-1][j],c[i-1][j-1]);
	}
	all=1; for(int i=1;i<=(2*n);i+=2) all=1ll*all*i%P;
	//cout<<all<<endl;
	
	o=0; w=1; f[o][0][0][0]=1;
	for(int i=0,val;i<2*n;i++,swap(o,w)) 
		for(int j=0;j<=i;j++) 
			for(int k=0;k+j<=i;k++) {
				/*cout<<endl;
				cout<<i<<" "<<j<<" "<<k<<endl;
				cout<<0<<" "<<f[o][j][k][0]<<endl;
				cout<<1<<" "<<f[o][j][k][1]<<endl;
				cout<<2<<" "<<f[o][j][k][2]<<endl;
				*/
				// l
				int *F = f[o][j][k];
				inc(f[w][j][k+1][1],pls(F[0],F[1]));
				inc(f[w][j][k+1][2],F[2]);
				// r 1
				if(k) nc(f[w][j+k-1][0][0],F[1]);
				if(j) inc(f[w][j-1][k][0],F[2]);
				// r 2
				if(j>1) inc(f[w][j-1][k][2],1ll*(j-1)*F[2]%P);
				if(j>0) {
					inc(f[w][j-1][k][1],1ll*(j)*F[1]%P);
					inc(f[w][j-1][k][0],1ll*(j)*F[0]%P);
				}
				// r 3
				if(k) inc(f[w][j+k-1][0][2],1ll*(k-1)*F[1]%P);
				//clear
				f[o][j][k][0]=f[o][j][k][1]=f[o][j][k][2]=0;
			}
	dec(ans=all,f[o][0][0][0]);
	cout<<ans<<endl;
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:37:39: error: ‘nc’ was not declared in this scope; did you mean ‘n’?
   37 |                                 if(k) nc(f[w][j+k-1][0][0],F[1]);
      |                                       ^~
      |                                       n