結果

問題 No.2604 Initial Motion
ユーザー cho435cho435
提出日時 2024-01-12 23:45:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 864 bytes
コンパイル時間 4,884 ms
コンパイル使用メモリ 282,844 KB
実行使用メモリ 28,052 KB
最終ジャッジ日時 2024-01-12 23:45:24
合計ジャッジ時間 11,542 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,480 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 152 ms
17,652 KB
testcase_04 AC 156 ms
17,652 KB
testcase_05 AC 147 ms
17,652 KB
testcase_06 AC 151 ms
17,652 KB
testcase_07 AC 148 ms
17,652 KB
testcase_08 AC 152 ms
17,652 KB
testcase_09 AC 145 ms
17,652 KB
testcase_10 AC 150 ms
17,652 KB
testcase_11 AC 153 ms
17,652 KB
testcase_12 AC 148 ms
17,652 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using mint = atcoder::modint998244353;

int main(){
	int k,n,m;
	cin>>k>>n>>m;
	vector<int> a(k),b(n);
	rep(i,k) cin>>a.at(i);
	rep(i,n) cin>>b.at(i);
	rep(i,k) a.at(i)--;
	vector<vector<ll>> g(n,vector<ll>(n,1e18));
	rep(lp,m){
		int u,v;
		ll d;
		cin>>u>>v>>d;
		u--; v--;
		g.at(u).at(v)=d;
		g.at(v).at(u)=d;
	}
	rep(i,n) g.at(i).at(i)=0;
	{
		rep(i,n) rep(j,n) rep(k,n){
			if(g.at(j).at(k)>g.at(j).at(i)+g.at(i).at(k)){
				g.at(j).at(k)=g.at(j).at(i)+g.at(i).at(k);
			}
		}
	}
	atcoder::mcf_graph<ll,ll> mcf(k+n+2);
	rep(i,k) rep(j,n){
		mcf.add_edge(i,k+j,1,g.at(a.at(i)).at(j));
	}
	rep(i,k) mcf.add_edge(k+n,i,1,0);
	rep(i,n) mcf.add_edge(k+i,k+n+1,b.at(i),0);
	auto[mx,cs]=mcf.flow(k+n,k+n+1,k);
	cout<<cs<<endl;
}
0