結果
| 問題 | No.654 Air E869120 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-01-30 01:28:47 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 10 ms / 2,000 ms | 
| コード長 | 1,007 bytes | 
| コンパイル時間 | 7,251 ms | 
| コンパイル使用メモリ | 332,400 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2025-01-30 01:28:57 | 
| 合計ジャッジ時間 | 8,961 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 35 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::static_modint<998244353>;
//using mint = atcoder::static_modint<1000000007>;
using namespace std;
using namespace atcoder;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<n; i++)
const vector<int> dx{1,0,-1,0},dy{0,1,0,-1};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;cin >> n >> m;
    int d;cin >> d;
    mf_graph<ll> G(m*2+2);
    vector<vector<int>> uvpqw(m+1,vector<int>(5));
    rep(i,1,m+1)rep(j,0,5){
        cin >> uvpqw[i][j];
        G.add_edge(i,i+m,uvpqw[i][4]);
    }
    
    rep(i,1,m+1){
        if(uvpqw[i][0]==1)G.add_edge(0,i,uvpqw[i][4]);
        if(uvpqw[i][1]==n)G.add_edge(i+m,m*2+1,uvpqw[i][4]);
    }
    const ll inf=1e10;
    rep(i,1,m+1)rep(j,1,m+1)if(i!=j){
        if(uvpqw[i][3]+d<=uvpqw[j][2] && uvpqw[i][1]==uvpqw[j][0]){
            G.add_edge(i+m,j,inf);
        }
    }
    cout << G.flow(0,m*2+1);
}
            
            
            
        