結果

問題 No.1364 [Renaming] Road to Cherry from Zelkova
ユーザー chocoruskchocorusk
提出日時 2021-01-22 22:52:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,562 bytes
コンパイル時間 1,240 ms
コンパイル使用メモリ 132,120 KB
実行使用メモリ 9,820 KB
最終ジャッジ日時 2023-08-27 21:17:34
合計ジャッジ時間 4,270 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 4 ms
9,480 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 4 ms
9,476 KB
testcase_24 AC 4 ms
9,484 KB
testcase_25 AC 5 ms
9,492 KB
testcase_26 AC 4 ms
9,696 KB
testcase_27 AC 5 ms
9,476 KB
testcase_28 AC 4 ms
9,612 KB
testcase_29 AC 4 ms
9,628 KB
testcase_30 AC 4 ms
9,548 KB
testcase_31 AC 4 ms
9,532 KB
testcase_32 AC 4 ms
9,472 KB
testcase_33 AC 4 ms
9,544 KB
testcase_34 AC 5 ms
9,480 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 4 ms
9,472 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 4 ms
9,476 KB
testcase_46 WA -
testcase_47 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
struct SCC{
    vector<vector<int>> g, gr;
    int n, k;
    vector<int> cmp, vs;
    vector<bool> used;
    void dfs(int x){
        used[x]=1;
        for(auto y:g[x]){
            if(!used[y]) dfs(y);
        }
        vs.push_back(x);
    }
    void rdfs(int v, int k){
        used[v]=1;
        cmp[v]=k;
        for(auto y:gr[v]){
            if(!used[y]) rdfs(y, k);
        }
    }
    SCC(const vector<vector<int>> &g):g(g), n(g.size()), cmp(n), used(n){
        gr.resize(n);
        for(int x=0; x<n; x++) for(auto y:g[x]) gr[y].push_back(x);
        for(int i=0; i<n; i++){
            if(!used[i]) dfs(i);
        }
        fill(used.begin(), used.end(), 0);
        k=0;
        for(int i=vs.size()-1; i>=0; i--){
            if(!used[vs[i]]) rdfs(vs[i], k++);
        }
    }
};
int u[200010], v[200010];
ll l[200020], a[200020];
vector<P> g[200020];
int main()
{
    int n, m;
    cin>>n>>m;
    cout<<"INF"<<endl;
    return 0;
    vector<vector<int>> g0(n+1);
    for(int i=0; i<m; i++){
        cin>>u[i]>>v[i]>>l[i]>>a[i];
        g[u[i]].push_back({v[i], i});
        g0[u[i]].push_back(v[i]);
    }
    SCC scc(g0);
    vector<vector<int>> w(scc.k);
    for(int i=0; i<=n; i++){
        w[scc.cmp[i]].push_back(i);
    }
    bool dame[100010]={};
    for(int i=0; i<scc.k; i++){
        if(w[i].size()>1){
            for(auto x:w[i]) dame[x]=1;
        }
    }
    if(dame[0] || dame[n]){
        cout<<"INF"<<endl;
        return 0;
    }
    ll dp[100010]={};
    dp[0]=1;
    ll dps[100010]={};
    bool ok[100010]={};
    ok[0]=1;
    for(int i=0; i<scc.k; i++){
        if(w[i].size()>1) continue;
        int x=w[i][0];
        for(auto q:g[x]){
            int i=q.second;
            int y=q.first;
            if(dame[y]) continue;
            ok[y]=1;
            (dp[y]+=dp[x]*a[i])%=MOD;
            (dps[y]+=dps[x]*a[i]+dp[x]*l[i]%MOD*a[i])%=MOD;
        }
    }
    if(!ok[n]){
        cout<<"INF"<<endl;
    }else{
        cout<<dps[n]<<endl;
    }

    return 0;
}
0