結果
| 問題 |
No.3111 Toll Optimization
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2025-04-18 20:08:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 790 bytes |
| コンパイル時間 | 4,295 ms |
| コンパイル使用メモリ | 267,392 KB |
| 実行使用メモリ | 221,180 KB |
| 最終ジャッジ日時 | 2025-04-18 20:08:41 |
| 合計ジャッジ時間 | 19,713 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 RE * 14 |
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001LL
int main(){
int n,m,k;
cin>>n>>m>>k;
mcf_graph<int,long long> G(n*(k+1));
rep(i,n){
G.add_edge(i*(k+1),i*(k+1)+1,1,0);
}
vector<long long> a(m),b(m),c(m);
rep(i,m)cin>>c[i];
rep(i,m){
cin>>a[i]>>b[i];
a[i]--,b[i]--;
}
rep(i,m){
rep(_,2){
rep(j,k+1){
G.add_edge(a[i]*(k+1)+j,b[i]*(k+1)+j,1,c[i]);
if(j!=k){
G.add_edge(a[i]*(k+1)+j,b[i]*(k+1)+j+1,1,0);
}
}
swap(a[i],b[i]);
}
}
auto ans = G.flow(0,n*(k+1)-1,1);
if(ans.first==0)cout<<-1<<endl;
else cout<<ans.second<<endl;
return 0;
}
沙耶花