結果

問題 No.2464 To DAG
ユーザー hirayuu_ychirayuu_yc
提出日時 2023-08-26 07:00:23
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 786 bytes
コンパイル時間 7,362 ms
コンパイル使用メモリ 316,884 KB
実行使用メモリ 77,280 KB
最終ジャッジ日時 2023-08-28 19:27:05
合計ジャッジ時間 20,885 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,356 KB
testcase_01 AC 1 ms
4,360 KB
testcase_02 AC 403 ms
74,624 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 202 ms
24,700 KB
testcase_23 AC 210 ms
24,096 KB
testcase_24 AC 201 ms
27,860 KB
testcase_25 AC 201 ms
27,660 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 213 ms
27,556 KB
testcase_36 AC 200 ms
27,764 KB
testcase_37 AC 131 ms
27,308 KB
testcase_38 AC 131 ms
27,748 KB
testcase_39 AC 73 ms
57,396 KB
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

int main() {
    int N,M;
    cin>>N>>M;
    vector<int> d(N);
    mf_graph<int> gr(N+2);
    for(int i=0; i<M; i++){
        int U,V;
        cin>>U>>V;
        d[U-1]+=1;
        d[V-1]-=1;
        gr.add_edge(U-1,V-1,1);
    }
    for(int i=0; i<N; i++){
        gr.add_edge(N,i,300000);
        gr.add_edge(i,N+1,300000-d[i]);
    }
    vector<pair<int,int>> ans(0);
    gr.flow(N,N+1);
    for(mf_graph<int>::edge i:gr.edges()){
        if(i.flow==0 or i.from==N or i.to==N+1){
            continue;
        }
        ans.push_back(make_pair(i.from+1,i.to+1));
    }
    cout<<N<<" "<<ans.size()<<endl;
    for(pair<int,int> i: ans){
        cout<<i.first<<" "<<i.second<<endl;
    }
}
0