結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 345 ms
74,924 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 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 195 ms
25,312 KB
testcase_23 AC 203 ms
24,088 KB
testcase_24 AC 188 ms
28,412 KB
testcase_25 AC 189 ms
29,776 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 209 ms
27,784 KB
testcase_36 AC 195 ms
28,016 KB
testcase_37 AC 125 ms
28,348 KB
testcase_38 AC 123 ms
28,508 KB
testcase_39 AC 69 ms
60,604 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);
    cerr<<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