結果
問題 | No.1667 Forest |
ユーザー | chocorusk |
提出日時 | 2021-09-03 21:47:05 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 221 ms / 3,000 ms |
コード長 | 1,453 bytes |
コンパイル時間 | 3,298 ms |
コンパイル使用メモリ | 188,760 KB |
実行使用メモリ | 19,616 KB |
最終ジャッジ日時 | 2023-08-21 20:58:41 |
合計ジャッジ時間 | 5,725 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 221 ms
19,328 KB |
testcase_01 | AC | 220 ms
19,512 KB |
testcase_02 | AC | 215 ms
19,508 KB |
testcase_03 | AC | 9 ms
19,416 KB |
testcase_04 | AC | 213 ms
19,376 KB |
testcase_05 | AC | 125 ms
19,392 KB |
testcase_06 | AC | 77 ms
19,616 KB |
testcase_07 | AC | 49 ms
19,420 KB |
testcase_08 | AC | 26 ms
19,388 KB |
testcase_09 | AC | 18 ms
19,352 KB |
testcase_10 | AC | 12 ms
19,512 KB |
testcase_11 | AC | 8 ms
19,396 KB |
testcase_12 | AC | 7 ms
19,404 KB |
testcase_13 | AC | 8 ms
19,452 KB |
testcase_14 | AC | 8 ms
19,424 KB |
testcase_15 | AC | 7 ms
19,444 KB |
testcase_16 | AC | 7 ms
19,404 KB |
testcase_17 | AC | 7 ms
19,416 KB |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #include <list> #include <atcoder/all> #define popcount __builtin_popcount using namespace std; using namespace atcoder; typedef long long ll; typedef pair<int, int> P; // using mint=modint998244353; using mint=modint; mint f[2000010], invf[2000010]; void fac(int n){ f[0]=1; for(ll i=1; i<=n; i++) f[i]=f[i-1]*i; invf[n]=f[n].inv(); for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1); } mint comb(int x, int y){ if(!(0<=y && y<=x)) return 0; return f[x]*invf[y]*invf[x-y]; } mint dp[303][303]; int main() { int n, mod; cin>>n>>mod; mint::set_mod(mod); fac(n); for(int i=1; i<=n; i++){ mint x=1; if(i>1) x=mint(i).pow(i-2); dp[i][i-1]+=x; for(int j=0; j<i; j++){ for(int k=1; k+i<=n; k++){ mint y=1; if(k>1) y=mint(k).pow(k-2); dp[i+k][j+k-1]+=dp[i][j]*comb(i+k-1, k-1)*y; } } } for(int i=0; i<n; i++){ cout<<dp[n][i].val()<<endl; } return 0; }