結果
問題 | No.2320 Game World for PvP |
ユーザー | kotatsugame |
提出日時 | 2023-05-26 22:24:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 687 bytes |
コンパイル時間 | 1,125 ms |
コンパイル使用メモリ | 86,448 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 08:10:14 |
合計ジャッジ時間 | 2,377 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include<iostream> #include<atcoder/maxflow> using namespace std; int N,S,T; int C[60][60]; int sign[60]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>S>>T; for(int i=0;i<S;i++) { int u;cin>>u; u--; sign[u]=1; } for(int i=0;i<T;i++) { int u;cin>>u; u--; sign[u]=-1; } for(int i=0;i<N;i++)for(int j=0;j<N;j++)cin>>C[i][j]; atcoder::mf_graph<long>G(N+2); int source=N,sink=N+1; long ans=0; for(int i=0;i<N;i++) { if(sign[i]==1)G.add_edge(source,i,(long)1e15); if(sign[i]==-1)G.add_edge(i,sink,(long)1e15); for(int j=0;j<N;j++)if(i!=j) { G.add_edge(i,j,C[i][j]); ans+=C[i][j]; } } cout<<ans/2-G.flow(source,sink)<<endl; }