CODE FESTIVAL 2016 Final

Submission #5484774

Source codeソースコード

#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

const i32 mod = 1000000007;

#define POS(i, j, k) ((((i) & 1) * (n + 1) + (j)) * (n + 1) + (k))

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  i32 *dp = (i32 *) calloc (2 * (n + 1) * (n + 1), sizeof (i32));
  dp[POS(0, n, 0)] = 1;
  for (i32 i = 1; i <= m; ++i) {
    for (i32 j = 1; j <= n; ++j) {
      for (i32 k = 0; k <= n - j; ++k) {
        i64 local = (i64) j * dp[POS(i - 1, j + k, 0)];
        if (k > 0) local += (i64) k * dp[POS(i - 1, j, k)];
        if (n - j - k > 0) local += (i64) (n - j - k) * dp[POS(i - 1, j, k + 1)];
        dp[POS(i, j, k)] = local % mod;
      }
    }
  }
  printf ("%" PRIi32 "\n", dp[POS(m, 1, 0)]);
}

int main (void) {
  run();
  return 0;
}

Submission

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

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

./Main.c: In function ‘run’:
./Main.c:15:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf ("%" SCNi32 "%" SCNi32, &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 128 KB
01-02.txt AC 1 ms 128 KB
01-03.txt AC 1 ms 128 KB
01-04.txt AC 1 ms 896 KB
01-05.txt AC 1 ms 128 KB
01-06.txt AC 5 ms 256 KB
01-07.txt AC 45 ms 768 KB
01-08.txt AC 47 ms 896 KB
01-09.txt AC 48 ms 896 KB
01-10.txt AC 48 ms 896 KB
sample-01.txt AC 1 ms 128 KB
sample-02.txt AC 13 ms 384 KB
sample-03.txt AC 24 ms 896 KB