CODE FESTIVAL 2016 Final

Submission #5428284

Source codeソースコード

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,m;
ll dp[302][302][302];

int main(){
  cin >> n >> m;
  dp[0][1][1] = 1;
  for(ll i = 0;i < m;i++){
    for(ll j = 1;j <= n;j++){
      for(ll k = 1;k <= n;k++){
        dp[i][j][k] %= mod;
        dp[i+1][j+1][k] += dp[i][j][k]*(n-j);
        dp[i+1][j][k] += dp[i][j][k]*(j-k);
        dp[i+1][j][j] += dp[i][j][k]*k;
      }
    }
  }
  cout << dp[m][n][n]%mod << endl;
}

Submission

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

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 46 ms 213248 KB
01-04.txt AC 2 ms 1664 KB
01-05.txt AC 43 ms 213376 KB
01-06.txt AC 52 ms 213888 KB
01-07.txt AC 138 ms 215168 KB
01-08.txt AC 144 ms 215296 KB
01-09.txt AC 144 ms 215296 KB
01-10.txt AC 145 ms 215296 KB
sample-01.txt AC 2 ms 2304 KB
sample-02.txt AC 69 ms 214272 KB
sample-03.txt AC 74 ms 108800 KB