CODE FESTIVAL 2016 Final

Submission #992457

Source codeソースコード

#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M;
i64 dp[303][303][303]; // day, unvis, size of 0 unit

int main()
{
	scanf("%d%d", &N, &M);
	for (int i = 0; i <= M; ++i) {
		for (int j = 0; j <= N; ++j) {
			for (int k = 0; k <= N; ++k) {
				dp[i][j][k] = 0;
			}
		}
	}
	dp[0][N - 1][1] = 1;
	for (int i = 0; i < M; ++i) {
		for (int j = 0; j <= N; ++j) {
			for (int k = 0; k <= N; ++k) if (dp[i][j][k]) {
				ADD(dp[i + 1][j][N - j], k * dp[i][j][k]);
				if (j > 0) ADD(dp[i + 1][j - 1][k], j * dp[i][j][k]);
				ADD(dp[i + 1][j][k], (N - k - j) * dp[i][j][k]);
			}
		}
	}
	printf("%lld\n", dp[M][0][N]);
	return 0;
}

Submission

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

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

./Main.cpp: In function ‘int main()’:
./Main.cpp:25:23: 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 3 ms 256 KB
01-02.txt AC 2 ms 256 KB
01-03.txt AC 6 ms 2816 KB
01-04.txt AC 4 ms 1664 KB
01-05.txt AC 11 ms 8576 KB
01-06.txt AC 74 ms 65024 KB
01-07.txt AC 250 ms 208128 KB
01-08.txt AC 257 ms 214528 KB
01-09.txt AC 259 ms 215168 KB
01-10.txt AC 259 ms 215936 KB
sample-01.txt AC 3 ms 256 KB
sample-02.txt AC 127 ms 108672 KB
sample-03.txt AC 121 ms 108416 KB