結果
問題 |
No.2464 To DAG
|
ユーザー |
|
提出日時 | 2023-08-26 07:42:07 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 831 bytes |
コンパイル時間 | 6,695 ms |
コンパイル使用メモリ | 329,740 KB |
実行使用メモリ | 145,248 KB |
最終ジャッジ日時 | 2024-12-30 05:41:46 |
合計ジャッジ時間 | 115,308 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 5 WA * 1 TLE * 33 |
ソースコード
#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); mcf_graph<int,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,1); } for(int i=0; i<N; i++){ gr.add_edge(N,i,300000,0); gr.add_edge(i,N+1,300000-d[i],0); } vector<pair<int,int>> ans(0); cerr<<gr.flow(N,N+1).first; for(mcf_graph<int,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)); } printf("%d %d\n",N,(int)ans.size()); for(pair<int,int> i: ans){ printf("%d %d\n",i.first,i.second); } }