結果
問題 | No.1111 コード進行 |
ユーザー | FF256grhy |
提出日時 | 2020-07-10 22:56:49 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 251 ms / 2,000 ms |
コード長 | 4,390 bytes |
コンパイル時間 | 4,183 ms |
コンパイル使用メモリ | 211,372 KB |
実行使用メモリ | 218,496 KB |
最終ジャッジ日時 | 2024-10-11 13:36:50 |
合計ジャッジ時間 | 7,163 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
6,912 KB |
testcase_01 | AC | 4 ms
6,016 KB |
testcase_02 | AC | 3 ms
5,504 KB |
testcase_03 | AC | 4 ms
5,376 KB |
testcase_04 | AC | 4 ms
5,376 KB |
testcase_05 | AC | 5 ms
6,016 KB |
testcase_06 | AC | 7 ms
9,600 KB |
testcase_07 | AC | 11 ms
13,312 KB |
testcase_08 | AC | 11 ms
12,672 KB |
testcase_09 | AC | 6 ms
6,784 KB |
testcase_10 | AC | 13 ms
16,768 KB |
testcase_11 | AC | 9 ms
11,136 KB |
testcase_12 | AC | 8 ms
9,600 KB |
testcase_13 | AC | 7 ms
8,960 KB |
testcase_14 | AC | 11 ms
12,544 KB |
testcase_15 | AC | 13 ms
15,360 KB |
testcase_16 | AC | 9 ms
10,368 KB |
testcase_17 | AC | 14 ms
16,768 KB |
testcase_18 | AC | 9 ms
12,544 KB |
testcase_19 | AC | 4 ms
5,504 KB |
testcase_20 | AC | 5 ms
6,784 KB |
testcase_21 | AC | 11 ms
13,952 KB |
testcase_22 | AC | 13 ms
16,256 KB |
testcase_23 | AC | 9 ms
11,776 KB |
testcase_24 | AC | 9 ms
10,368 KB |
testcase_25 | AC | 15 ms
16,896 KB |
testcase_26 | AC | 14 ms
14,720 KB |
testcase_27 | AC | 5 ms
6,016 KB |
testcase_28 | AC | 114 ms
131,840 KB |
testcase_29 | AC | 113 ms
126,208 KB |
testcase_30 | AC | 86 ms
87,552 KB |
testcase_31 | AC | 17 ms
21,120 KB |
testcase_32 | AC | 201 ms
164,736 KB |
testcase_33 | AC | 83 ms
56,960 KB |
testcase_34 | AC | 97 ms
111,104 KB |
testcase_35 | AC | 167 ms
192,640 KB |
testcase_36 | AC | 143 ms
133,376 KB |
testcase_37 | AC | 134 ms
123,264 KB |
testcase_38 | AC | 116 ms
88,960 KB |
testcase_39 | AC | 118 ms
83,456 KB |
testcase_40 | AC | 157 ms
140,416 KB |
testcase_41 | AC | 138 ms
154,752 KB |
testcase_42 | AC | 139 ms
131,840 KB |
testcase_43 | AC | 110 ms
85,504 KB |
testcase_44 | AC | 73 ms
76,928 KB |
testcase_45 | AC | 122 ms
129,792 KB |
testcase_46 | AC | 226 ms
218,368 KB |
testcase_47 | AC | 226 ms
218,496 KB |
testcase_48 | AC | 251 ms
218,496 KB |
testcase_49 | AC | 251 ms
218,496 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using LL = long long int; #define incID(i, l, r) for(int i = (l) ; i < (r); ++i) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i) #define incII(i, l, r) for(int i = (l) ; i <= (r); ++i) #define decII(i, l, r) for(int i = (r) ; i >= (l); --i) #define inc(i, n) incID(i, 0, n) #define dec(i, n) decID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec1(i, n) decII(i, 1, n) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define MT make_tuple #define FI first #define SE second #define FR front() #define BA back() #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() auto setmin = [](auto & a, auto b) { return (b < a ? a = b, true : false); }; auto setmax = [](auto & a, auto b) { return (b > a ? a = b, true : false); }; auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); }; auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); }; #define SI(v) static_cast<int>(v.size()) #define RF(e, v) for(auto & e: v) #define until(e) while(! (e)) #define if_not(e) if(! (e)) #define ef else if #define UR assert(false) #define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__); void IN_() { }; template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); }; template<typename T > void OUT(T && a ) { cout << a << endl; } template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); } // ---- ---- template<LL M> class ModInt { private: LL v; pair<LL, LL> ext_gcd(LL a, LL b) { if(b == 0) { assert(a == 1); return { 1, 0 }; } auto p = ext_gcd(b, a % b); return { p.SE, p.FI - (a / b) * p.SE }; } public: ModInt(LL vv = 0) { v = vv; if(abs(v) >= M) { v %= M; } if(v < 0) { v += M; } } LL get_v() { return v; } ModInt inv() { return ext_gcd(M, v).SE; } ModInt exp(LL b) { ModInt p = 1, a = v; if(b < 0) { a = a.inv(); b = -b; } while(b) { if(b & 1) { p *= a; } a *= a; b >>= 1; } return p; } friend bool operator< (ModInt a, ModInt b) { return (a.v < b.v); } friend bool operator> (ModInt a, ModInt b) { return (a.v > b.v); } friend bool operator<=(ModInt a, ModInt b) { return (a.v <= b.v); } friend bool operator>=(ModInt a, ModInt b) { return (a.v >= b.v); } friend bool operator==(ModInt a, ModInt b) { return (a.v == b.v); } friend bool operator!=(ModInt a, ModInt b) { return (a.v != b.v); } friend ModInt operator+ (ModInt a ) { return ModInt(+a.v); } friend ModInt operator- (ModInt a ) { return ModInt(-a.v); } friend ModInt operator+ (ModInt a, ModInt b) { return ModInt(a.v + b.v); } friend ModInt operator- (ModInt a, ModInt b) { return ModInt(a.v - b.v); } friend ModInt operator* (ModInt a, ModInt b) { return ModInt(a.v * b.v); } friend ModInt operator/ (ModInt a, ModInt b) { return a * b.inv(); } friend ModInt operator^ (ModInt a, LL b) { return a.exp(b); } friend ModInt & operator+=(ModInt & a, ModInt b) { return (a = a + b); } friend ModInt & operator-=(ModInt & a, ModInt b) { return (a = a - b); } friend ModInt & operator*=(ModInt & a, ModInt b) { return (a = a * b); } friend ModInt & operator/=(ModInt & a, ModInt b) { return (a = a / b); } friend ModInt & operator^=(ModInt & a, LL b) { return (a = a ^ b); } friend istream & operator>>(istream & s, ModInt & b) { s >> b.v; b = ModInt(b.v); return s; } friend ostream & operator<<(ostream & s, ModInt b) { return (s << b.v); } }; // ---- using MI = ModInt<1'000'000'007>; template<typename T> T MV(T v) { return v; } template<typename T, typename ... U> auto MV(T v, int a, U ... b) { return vector<decltype(MV(v, b ...))>(a, MV(v, b ...)); } int main() { IN(int, n, m, k); n--; auto dp = MV<MI>(0, n + 1, 300, 301); vector<array<int, 3>> edge; inc(i, m) { IN(int, a, b, c); a--; b--; edge.PB({ a, b, c }); } inc(v, 300) { dp[0][v][0] = 1; } inc(i, n) { for(auto [a, b, c]: edge) { inc(s, 301) { if(s + c > 300) { break; } dp[i + 1][b][s + c] += dp[i][a][s]; } } } MI ans = 0; inc(v, 300) { ans += dp[n][v][k]; } OUT(ans); }