Submission #56409
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | #include "bits/stdc++.h" // Begin Header {{{ #define all(x) (x).begin(), (x).end() #define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i) #define reps(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i) #define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i) #define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__) #ifndef DBG #define trace(...) #endif using namespace std; using i64 = int_fast64_t; using pii = pair<i64, i64>; template < class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true ); } template < class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true ); } inline i64 sigma(i64 n) { return (n * (n + 1) >> 1); } inline i64 updiv(i64 a, i64 b) { return (a + b - 1) / b; } inline i64 sqr(i64 n) { return n * n; } inline string to_string( char c) { return string(1, c); } constexpr int INF = 0x3f3f3f3f; constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL; template < class T> inline vector<T> make_v( const T &initValue, size_t sz) { return vector<T>(sz, initValue); } template < class T, class ... Args> inline auto make_v( const T &initValue, size_t sz, Args... args) { return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...)); } inline void input() {} template < class Head, class ... Tail> inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); } inline void print() { cout << "\n" ; } template < class Head, class ... Tail> inline void print(Head &&head, Tail&&... tail) { cout << head; if ( sizeof ...(tail)) cout << ' ' ; print(forward<Tail>(tail)...); } template < class T> inline ostream& operator<< (ostream &out, const vector<T> &vec) { static constexpr const char *delim[] = { " " , "" }; for ( const auto &e : vec) out << e << delim[&e == &vec.back()]; return out; } template < typename Func> struct FixPoint : Func { inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {} template < typename ... Args> inline decltype(auto) operator()(Args &&... args) const { return Func::operator()(* this , forward<Args>(args)...); } }; template < typename Func > inline decltype(auto) makeFixPoint(Func &&f) { return FixPoint< Func >{forward< Func >(f)}; } // }}} End Header constexpr int MOD = int (1e9) + 7; signed main() { ios::sync_with_stdio( false ); cin.tie(nullptr); var( int , N, M); static i64 dp[3005][3005]; dp[0][1] = 1; rep(cnt, M) { reps(i, 1, N) { if (i != N) { (dp[cnt+1][i+1] += dp[cnt][i]) %= MOD; } if (i != 1) { (dp[cnt+1][i-1] += dp[cnt][i]) %= MOD; } (dp[cnt+1][i] += dp[cnt][i]) %= MOD; } } print(dp[M][N]); return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 1107 - 脱出ゲーム |
ユーザー名 | Arumakan_ei1727 |
投稿日時 | 2019-11-13 18:34:53 |
言語 | C++14 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 2904 Byte |
最大実行時間 | 89 ms |
最大メモリ使用量 | 71004 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
case01.in | AC | 66 ms | 71004 KB |
1
|
case02.in | AC | 89 ms | 70796 KB |
1
|
case03.in | AC | 73 ms | 70864 KB |
1
|
case04.in | AC | 47 ms | 70316 KB |
1
|
case05.in | AC | 41 ms | 69936 KB |
1
|
case06.in | AC | 44 ms | 40976 KB |
1
|
case07.in | AC | 27 ms | 68608 KB |
1
|
case08.in | AC | 29 ms | 68712 KB |
1
|
case09.in | AC | 43 ms | 70092 KB |
1
|
case10.in | AC | 19 ms | 11956 KB |
1
|
sample01.in | AC | 24 ms | 648 KB |
1
|
sample02.in | AC | 27 ms | 592 KB |
1
|
sample03.in | AC | 29 ms | 784 KB |
1
|