結果
| 問題 |
No.2464 To DAG
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-26 07:33:46 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 809 bytes |
| コンパイル時間 | 6,761 ms |
| コンパイル使用メモリ | 318,356 KB |
| 実行使用メモリ | 93,344 KB |
| 最終ジャッジ日時 | 2024-12-30 05:38:53 |
| 合計ジャッジ時間 | 39,837 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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));
}
printf("%d %d\n",N,(int)ans.size());
for(pair<int,int> i: ans){
printf("%d %d\n",i.first,i.second);
}
}