結果

問題 No.1111 コード進行
ユーザー ysystem7ysystem7
提出日時 2020-07-10 22:29:01
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 2,625 bytes
コンパイル時間 2,631 ms
コンパイル使用メモリ 204,380 KB
実行使用メモリ 163,712 KB
最終ジャッジ日時 2024-04-19 17:38:41
合計ジャッジ時間 5,135 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 5 ms
6,400 KB
testcase_07 AC 8 ms
9,472 KB
testcase_08 AC 9 ms
8,320 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 4 ms
5,760 KB
testcase_11 AC 6 ms
7,168 KB
testcase_12 AC 5 ms
7,552 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 8 ms
9,472 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 5 ms
7,168 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 4 ms
6,400 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 4 ms
6,144 KB
testcase_25 AC 14 ms
12,672 KB
testcase_26 AC 12 ms
11,776 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 4 ms
5,376 KB
testcase_29 AC 6 ms
5,376 KB
testcase_30 AC 90 ms
85,632 KB
testcase_31 AC 14 ms
16,896 KB
testcase_32 AC 194 ms
163,712 KB
testcase_33 AC 77 ms
55,424 KB
testcase_34 AC 7 ms
8,576 KB
testcase_35 AC 3 ms
5,376 KB
testcase_36 AC 29 ms
6,912 KB
testcase_37 AC 35 ms
15,104 KB
testcase_38 AC 116 ms
80,896 KB
testcase_39 AC 111 ms
81,664 KB
testcase_40 AC 162 ms
132,096 KB
testcase_41 AC 6 ms
5,376 KB
testcase_42 AC 31 ms
12,032 KB
testcase_43 AC 101 ms
75,648 KB
testcase_44 AC 8 ms
5,376 KB
testcase_45 AC 10 ms
5,376 KB
testcase_46 AC 50 ms
5,376 KB
testcase_47 AC 50 ms
5,376 KB
testcase_48 AC 52 ms
5,376 KB
testcase_49 AC 64 ms
16,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

const int mx=305;

ll dp[mx][mx][mx];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m,kk;
    cin>>n>>m>>kk;
    V<int> p(m),q(m),c(m);
    rep(i,m)cin>>p[i]>>q[i]>>c[i];
    map<P,int> mp;
    rep(i,m)mp[make_pair(p[i],q[i])]=c[i]+1;
    //if(n%2==1)cout<<1<<endl;
    {
        rep(i,m)dp[2][c[i]][q[i]]++;
        for(int i=2;i<n;i++){
            for(int j=0;j<=300;j++){
                for(int k=0;k<m;k++){
                    ll x=j+c[k];
                    if(x<=300&&dp[i][j][p[k]]>0){
                        dp[i+1][x][q[k]]=(dp[i+1][x][q[k]]+dp[i][j][p[k]])%mod;
                    }
                }
            }
        }
    }
    ll ans=0;
    for(int i=0;i<=300;i++)ans=(ans+dp[n][kk][i])%mod;
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない ACできると信じろ!!!
//どうしてもわからないときはサンプルで実験 何か見えてくるかも
//頭で考えてダメなら紙におこせ!!
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ!
(適切にmodをとれ にぶたんで途中で切り上げろ)
制約をよく読め!
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意!(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ!
doubleを扱うときには(abs)ではなく'fabs'!!!
*/
0