結果
| 問題 | No.2464 To DAG |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-26 07:42:07 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 831 bytes |
| 記録 | |
| コンパイル時間 | 5,605 ms |
| コンパイル使用メモリ | 390,212 KB |
| 実行使用メモリ | 141,176 KB |
| 最終ジャッジ日時 | 2026-06-03 21:49:30 |
| 合計ジャッジ時間 | 10,625 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | TLE * 1 -- * 38 |
ソースコード
#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);
}
}