結果

問題 No.2464 To DAG
ユーザー hirayuu_ychirayuu_yc
提出日時 2023-08-26 07:29:42
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 804 bytes
コンパイル時間 7,518 ms
コンパイル使用メモリ 315,604 KB
実行使用メモリ 95,252 KB
最終ジャッジ日時 2023-08-28 19:27:34
合計ジャッジ時間 42,231 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 562 ms
92,120 KB
testcase_03 TLE -
testcase_04 AC 1,607 ms
91,360 KB
testcase_05 AC 1,201 ms
90,644 KB
testcase_06 AC 1,032 ms
90,432 KB
testcase_07 WA -
testcase_08 AC 1,269 ms
50,344 KB
testcase_09 AC 864 ms
46,896 KB
testcase_10 AC 727 ms
46,348 KB
testcase_11 AC 550 ms
39,656 KB
testcase_12 AC 432 ms
27,696 KB
testcase_13 AC 448 ms
37,852 KB
testcase_14 AC 801 ms
70,728 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1 ms
4,352 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 221 ms
36,924 KB
testcase_23 AC 230 ms
35,456 KB
testcase_24 AC 222 ms
40,180 KB
testcase_25 AC 215 ms
40,252 KB
testcase_26 AC 205 ms
22,748 KB
testcase_27 AC 1,409 ms
93,600 KB
testcase_28 AC 1,435 ms
93,016 KB
testcase_29 AC 1,291 ms
95,252 KB
testcase_30 AC 1,054 ms
48,448 KB
testcase_31 AC 1,111 ms
42,808 KB
testcase_32 AC 1,131 ms
40,140 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 220 ms
35,076 KB
testcase_36 AC 213 ms
35,952 KB
testcase_37 AC 142 ms
35,148 KB
testcase_38 AC 143 ms
35,816 KB
testcase_39 AC 94 ms
76,576 KB
testcase_40 AC 97 ms
73,256 KB
権限があれば一括ダウンロードができます

ソースコード

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<long long> 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<long long>::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