結果
問題 |
No.2464 To DAG
|
ユーザー |
|
提出日時 | 2023-08-26 07:00:23 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 786 bytes |
コンパイル時間 | 6,424 ms |
コンパイル使用メモリ | 318,832 KB |
実行使用メモリ | 77,260 KB |
最終ジャッジ日時 | 2024-12-30 05:38:08 |
合計ジャッジ時間 | 23,584 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 WA * 26 |
ソースコード
#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; } }