AtCoder Grand Contest 005

Submission #1365824

Source codeソースコード

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read()
{
	int t=1,sum=0;char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') t=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		sum=sum*10+ch-'0',ch=getchar();
	return t*sum;
}
const int Max=2e3+10,mod=924844033;
int f[Max<<1][Max][2],g[Max],fac[Max],vis[Max][2],a[Max],n,m,tot;
int main()
{
	int i,j,x,y;
	n=read(); m=read();
	for(i=1;i<=n;i++)
		for(j=0;j<2;j++) if(!vis[i][j])
		{
			int len=0;
			for(x=i,y=j;x<=n;x+=m,y^=1)
				vis[x][y]=1,len++;
			tot+=len;
			a[tot]=1;
		}
	f[0][0][1]=1;
	for(i=1;i<=tot;i++)
		for(j=0;j<=i/2;j++)
		{
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%mod;
			if(j&&!a[i-1])
				f[i][j][1]=f[i-1][j-1][0];
		}
	for(i=0;i<=n;i++) g[i]=(f[tot][i][0]+f[tot][i][1])%mod;
	for(fac[0]=i=1;i<=n;i++) fac[i]=1LL*fac[i-1]*i%mod;
	int ans=0;
	for(i=0;i<=n;i++)
		if(i&1)
			ans=(ans-1LL*g[i]*fac[n-i]%mod)%mod;
		else 
			ans=(ans+1LL*g[i]*fac[n-i]%mod)%mod;
	printf("%d\n",(ans+mod)%mod);
	return 0;
}

Submission

Task問題 D - ~K Perm Counting
User nameユーザ名 c_2h
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1069 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - example0,example1,example2,example3,example4
All 0 / 900 example0,example1,example2,example3,example4,handmade0,handmade1,handmade2,handmade3,handmade4,handmade5,handmade6,maxrand0,maxrand1,maxrand2,maxrand3,maxrand4,rand0,rand1,rand2,rand3,rand4,small0,small1,small2,supersmall0,supersmall1,supersmall2

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
example0 AC 1 ms 256 KB
example1 AC 1 ms 256 KB
example2 AC 1 ms 256 KB
example3 AC 1 ms 256 KB
example4 AC 4 ms 13056 KB
handmade0 AC 1 ms 128 KB
handmade1 WA
handmade2 AC 21 ms 61568 KB
handmade3 WA
handmade4 AC 19 ms 58112 KB
handmade5 WA
handmade6 WA
maxrand0 AC 20 ms 60160 KB
maxrand1 WA
maxrand2 WA
maxrand3 WA
maxrand4 AC 20 ms 60160 KB
rand0 WA
rand1 AC 5 ms 19200 KB
rand2 AC 6 ms 21248 KB
rand3 AC 1 ms 2816 KB
rand4 AC 18 ms 56064 KB
small0 AC 2 ms 8960 KB
small1 AC 2 ms 4864 KB
small2 AC 2 ms 6912 KB
supersmall0 AC 1 ms 128 KB
supersmall1 AC 1 ms 256 KB
supersmall2 AC 1 ms 256 KB