結果
| 問題 |
No.2464 To DAG
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-26 07:29:42 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 804 bytes |
| コンパイル時間 | 7,116 ms |
| コンパイル使用メモリ | 318,728 KB |
| 実行使用メモリ | 93,216 KB |
| 最終ジャッジ日時 | 2024-12-30 05:39:46 |
| 合計ジャッジ時間 | 45,841 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 WA * 7 TLE * 1 |
ソースコード
#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;
}
}