CODE FESTIVAL 2016 Final (Parallel)

Submission #1331307

Source codeソースコード

#include<bits/stdc++.h>
using namespace std;
int d[333][333][333],n,m;
#define mod 1000000007
int add(int x,int y){
	return (x+=y)<mod?x:x-mod;
}
int mul(int x,int y){
	return (int)((long long int)x*y%mod);
}
void addto(int&x,int y){
	x = add(x,y);
}
int main(){
	scanf("%d%d",&n,&m);
	d[0][1][0] = 1;
	for(int i=0; i<m; i++)
	for(int j=1; j<=i+1 && j<=n; j++)
	for(int k=0; j+k<=n; k++){
		if(d[i][j][k]==0)continue;
		addto(d[i+1][j+k][0],mul(d[i][j][k],j));
		addto(d[i+1][j][k],mul(d[i][j][k],k));
		if(j+k<n)
		addto(d[i+1][j][k+1],mul(d[i][j][k],n-j-k));
	}
	printf("%d\n",d[m][n][0]);
	return 0;
}

Submission

Task問題 F - Road of the King
User nameユーザ名 Blue.Mary
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 1000
Source lengthソースコード長 633 Byte
File nameファイル名
Exec time実行時間 72 ms
Memory usageメモリ使用量 128384 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
^

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt,sample-03.txt
all 1000 / 1000 sample-01.txt,sample-02.txt,sample-03.txt,01-01.txt,01-02.txt,01-03.txt,01-04.txt,01-05.txt,01-06.txt,01-07.txt,01-08.txt,01-09.txt,01-10.txt,sample-01.txt,sample-02.txt,sample-03.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 1 ms 256 KB
01-02.txt AC 1 ms 256 KB
01-03.txt AC 26 ms 127232 KB
01-04.txt AC 1 ms 256 KB
01-05.txt AC 26 ms 127232 KB
01-06.txt AC 35 ms 127616 KB
01-07.txt AC 71 ms 128000 KB
01-08.txt AC 72 ms 128384 KB
01-09.txt AC 72 ms 128384 KB
01-10.txt AC 72 ms 128384 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 48 ms 127872 KB
sample-03.txt AC 21 ms 63744 KB