結果

問題 No.2320 Game World for PvP
ユーザー 👑 tatyam
提出日時 2023-05-02 18:29:18
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 1,290 ms
コンパイル使用メモリ 115,700 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-21 07:30:19
合計ジャッジ時間 2,676 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <climits>
#include <iostream>
#include <vector>
#include <atcoder/maxflow>
using namespace std;
using ll = long long;
const ll INF = LLONG_MAX / 4;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    int N, S, T;
    cin >> N >> S >> T;
    
    const int src = N, dst = N + 1;
    atcoder::mf_graph<ll> g(N + 2);
    while(S--) {
        int A;
        cin >> A;
        A--;
        g.add_edge(src, A, INF);
    }
    while(T--) {
        int B;
        cin >> B;
        B--;
        g.add_edge(B, dst, INF);
    }
    ll ans = 0;
    for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) {
        ll C;
        cin >> C;
        if(i < j) {
            ans += C;
            g.change_edge(g.add_edge(i, j, 0), C * 2, C);
        }
    }
    
    cout << ans - g.flow(src, dst) << endl;
}
0