Submission #993350


Source Code Expand

#include<cstdio>
#include<algorithm>

using namespace std;

const long long mod = 1000000007;

long long dp[330][330][2][2];
int N, M;

long long solve(){
	dp[1][0][0][0] = 1;
	int t = 0;
	for(int i = 0; i < M; ++i){
		for(int x = 0; x < 330; ++x) for(int y = 0; y < 330; ++y){
			for(int z = 0; z < 2; ++z) dp[x][y][z][t ^ 1] = 0;
		}
		for(int x = 0; x <= N; ++x){
			for(int y = 0; y <= N; ++y){
				dp[x][y][0][1 - t] += dp[x][y][0][t] * x;
				dp[x][y][0][1 - t] %= mod;
				dp[x][y + 1][1][1 - t] += dp[x][y][0][t] * (N - x);
				dp[x][y + 1][1][1 - t] %= mod;
				
				if(x + y <= N){
					dp[x + y][0][0][1 - t] += dp[x][y][1][t] * x;
					dp[x + y][0][0][1 - t] %= mod;
				}
				dp[x][y][1][1 - t] += dp[x][y][1][t] * y;
				dp[x][y][1][1 - t] %= mod;
				dp[x][y + 1][1][1 - t] += dp[x][y][1][t] * (N - x - y);
				dp[x][y + 1][1][1 - t] %= mod;
			}
		}
		t ^= 1;
	}
	long long tmp = dp[N][0][0][t];
	tmp %= mod;
	tmp += mod;
	tmp %= mod;
	return tmp;
}

int main(){
	scanf("%d%d", &N, &M);
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}

Submission Info

Submission Time
Task F - Road of the King
User wo01
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 1115 Byte
Status AC
Exec Time 303 ms
Memory 3584 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:45: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 sample all
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 3
AC × 13
Set Name Test Cases
sample sample-01.txt, sample-02.txt, sample-03.txt
all 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 AC 5 ms 3584 KB
01-02.txt AC 5 ms 3584 KB
01-03.txt AC 54 ms 3584 KB
01-04.txt AC 6 ms 3584 KB
01-05.txt AC 54 ms 3584 KB
01-06.txt AC 76 ms 3584 KB
01-07.txt AC 286 ms 3584 KB
01-08.txt AC 300 ms 3584 KB
01-09.txt AC 302 ms 3584 KB
01-10.txt AC 303 ms 3584 KB
sample-01.txt AC 5 ms 3584 KB
sample-02.txt AC 117 ms 3584 KB
sample-03.txt AC 154 ms 3584 KB