結果

問題 No.140 みんなで旅行
ユーザー ttkkggwwttkkggww
提出日時 2022-05-11 20:31:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 902 bytes
コンパイル時間 4,302 ms
コンパイル使用メモリ 262,376 KB
実行使用メモリ 814,196 KB
最終ジャッジ日時 2023-09-26 11:28:37
合計ジャッジ時間 9,449 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
次のファイルから読み込み:  /usr/include/atcoder/modint:1,
         次から読み込み:  /usr/include/atcoder/convolution.hpp:11,
         次から読み込み:  /usr/include/atcoder/convolution:1,
         次から読み込み:  /usr/include/atcoder/all:1,
         次から読み込み:  main.cpp:3:
メンバ関数 ‘atcoder::static_modint<m, <anonymous> >::mint& atcoder::static_modint<m, <anonymous> >::operator+=(const mint&) [with int m = 1000000007; std::enable_if_t<(1 <= m)>* <anonymous> = 0]’ 内,
    inlined from ‘void solve()’ at main.cpp:22:36:
/usr/include/atcoder/modint.hpp:75:9: 警告: iteration 599 invokes undefined behavior [-Waggressive-loop-optimizations]
   75 |         _v += rhs._v;
      |         ^~
main.cpp: 関数 ‘void solve()’ 内:
main.cpp:16:40: 備考: within this loop
   16 |                         for(int k = 0;k<600;k++){
      |                                       ~^~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
using mint = modint1000000007;

int n;
mint dp[600][600][600];

void solve(){
	dp[1][1][1] = 1;
	dp[1][2][0] = 1;
	for(int i = 1;i<n;i++){
		for(int j = 0;j<600-1;j++){
			for(int k = 0;k<600;k++){
				dp[i+1][j][k+1] += dp[i][j][k] *(j-k);
				dp[i+1][j][k] += dp[i][j][k] *k;

				dp[i+1][j][k] += dp[i][j][k] * j*(j-1);

				dp[i+1][j+1][k+1] += dp[i][j][k];
				dp[i+1][j+1][k] += dp[i][j][k]*j*2;
				dp[i+1][j+2][k] += dp[i][j][k];
			}
		}
	}
	mint ans = 0;
	for(int i = 0;i<=n;i++){
		//cerr<<i<<':'<<dp[n][i][i].val()<<endl;
		ans += dp[n][i][i];
	}
	/*
	for(int i = 0;i<10;i++){
		for(int j = 0;j<10;j++){
			cerr<<dp[2][i][j].val()<<' ';
		}
		cout<<endl;
	}
	*/
	cout<<ans.val()<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> n;
	solve();
}
0