CODE FESTIVAL 2016 Final

Submission #1336793

Source codeソースコード

#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 300 + 10;
int64 dp[N][N][N];

void add(int64& x, int64 y) {
  x = (x + y) % MOD;
}

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

Submission

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

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

./Main.cpp: In function ‘int main()’:
./Main.cpp:50:24: 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 44 ms 223488 KB
01-04.txt AC 1 ms 256 KB
01-05.txt AC 44 ms 223488 KB
01-06.txt AC 54 ms 225536 KB
01-07.txt AC 88 ms 223488 KB
01-08.txt AC 89 ms 225536 KB
01-09.txt AC 89 ms 225536 KB
01-10.txt AC 89 ms 225536 KB
sample-01.txt AC 2 ms 2304 KB
sample-02.txt AC 67 ms 225536 KB
sample-03.txt AC 28 ms 112896 KB