結果

問題 No.2604 Initial Motion
ユーザー kotatsugamekotatsugame
提出日時 2024-01-12 22:42:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 139 ms / 3,000 ms
コード長 1,244 bytes
コンパイル時間 1,262 ms
コンパイル使用メモリ 99,580 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-12 22:42:47
合計ジャッジ時間 4,450 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 5 ms
6,676 KB
testcase_04 AC 5 ms
6,676 KB
testcase_05 AC 5 ms
6,676 KB
testcase_06 AC 5 ms
6,676 KB
testcase_07 AC 5 ms
6,676 KB
testcase_08 AC 6 ms
6,676 KB
testcase_09 AC 5 ms
6,676 KB
testcase_10 AC 5 ms
6,676 KB
testcase_11 AC 5 ms
6,676 KB
testcase_12 AC 5 ms
6,676 KB
testcase_13 AC 84 ms
6,676 KB
testcase_14 AC 54 ms
6,676 KB
testcase_15 AC 37 ms
6,676 KB
testcase_16 AC 71 ms
6,676 KB
testcase_17 AC 105 ms
6,676 KB
testcase_18 AC 94 ms
6,676 KB
testcase_19 AC 94 ms
6,676 KB
testcase_20 AC 70 ms
6,676 KB
testcase_21 AC 54 ms
6,676 KB
testcase_22 AC 90 ms
6,676 KB
testcase_23 AC 61 ms
6,676 KB
testcase_24 AC 78 ms
6,676 KB
testcase_25 AC 59 ms
6,676 KB
testcase_26 AC 66 ms
6,676 KB
testcase_27 AC 47 ms
6,676 KB
testcase_28 AC 62 ms
6,676 KB
testcase_29 AC 80 ms
6,676 KB
testcase_30 AC 49 ms
6,676 KB
testcase_31 AC 67 ms
6,676 KB
testcase_32 AC 38 ms
6,676 KB
testcase_33 AC 3 ms
6,676 KB
testcase_34 AC 32 ms
6,676 KB
testcase_35 AC 72 ms
6,676 KB
testcase_36 AC 56 ms
6,676 KB
testcase_37 AC 3 ms
6,676 KB
testcase_38 AC 2 ms
6,676 KB
testcase_39 AC 2 ms
6,676 KB
testcase_40 AC 136 ms
6,676 KB
testcase_41 AC 139 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cassert>
#include<atcoder/mincostflow>
using namespace std;
int K,N,M;
int A[2000],B[2000];
vector<pair<int,long> >G[2000];
long dist[2000];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>K>>N>>M;
	for(int i=0;i<K;i++)
	{
		int a;cin>>a;
		A[a-1]++;
	}
	for(int i=0;i<N;i++)cin>>B[i];
	atcoder::mcf_graph<int,long>MF(N+N+2);
	int source=N+N,sink=N+N+1;
	for(int i=0;i<M;i++)
	{
		int u,v;
		long long d;
		cin>>u>>v>>d;
		u--,v--;
		//G[u].push_back(make_pair(v,d));
		//G[v].push_back(make_pair(u,d));
		MF.add_edge(u,v,K,d);
		MF.add_edge(v,u,K,d);
	}
	for(int i=0;i<N;i++)
	{
		if(A[i]>0)MF.add_edge(source,i,A[i],0);
		if(B[i]>0)MF.add_edge(i,sink,B[i],0);
		/*
		for(int j=0;j<N;j++)dist[j]=1e18;
		priority_queue<pair<long,int> >Q;
		dist[i]=0;
		Q.push(make_pair(dist[i],i));
		while(!Q.empty())
		{
			int u=Q.top().second;
			long d=-Q.top().first;
			Q.pop();
			if(dist[u]<d)continue;
			MF.add_edge(i,N+u,K,d);
			for(pair<int,long>e:G[u])
			{
				int v=e.first;
				long nd=d+e.second;
				if(dist[v]>nd)
				{
					dist[v]=nd;
					Q.push(make_pair(-nd,v));
				}
			}
		}
		*/
	}
	cout<<MF.flow(source,sink,K).second<<endl;
}
0