Submission #992457


Source Code Expand

Copy
#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 Info

Submission Time
Task F - Road of the King
User semiexp
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 1012 Byte
Status
Exec Time 259 ms
Memory 215936 KB

Compile Error

./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);
                       ^

Judge Result

Set Name Score / Max Score Test Cases
sample 0 / 0 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
Case Name Status Exec Time Memory
01-01.txt 3 ms 256 KB
01-02.txt 2 ms 256 KB
01-03.txt 6 ms 2816 KB
01-04.txt 4 ms 1664 KB
01-05.txt 11 ms 8576 KB
01-06.txt 74 ms 65024 KB
01-07.txt 250 ms 208128 KB
01-08.txt 257 ms 214528 KB
01-09.txt 259 ms 215168 KB
01-10.txt 259 ms 215936 KB
sample-01.txt 3 ms 256 KB
sample-02.txt 127 ms 108672 KB
sample-03.txt 121 ms 108416 KB