Pagini recente » Cod sursa (job #1689346) | Cod sursa (job #610866) | Cod sursa (job #2781255) | Cod sursa (job #3194716) | Cod sursa (job #1349552)
#include <fstream>
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#define mp(a,b) make_pair(a,b)
#define mx 1000000
//de lene pentru lemne
using namespace std;
ifstream f("maxflow.in");
ofstream g("maxflow.out");
int m,n;
vector< pair<int,int> > G[mx];// fisrt = nnod||second=flow
vector< pair<int,int> > GR[mx];
bool been[mx];
int ant[mx];
bool BFS(int source, int sink)//returns if there is a path from start to end
{
stack<int> S;
for(int i=1;i<=n;i++)
{
been[i]=false;
ant[i]=-1;
}
for(S.push(source);S.size();)
{
int actual=S.top();
S.pop();
if(actual==sink)
{
return true;
}
for(int i=0;i<G[actual].size();i++)
{
if(!been[G[actual][i].first] )/*&& G[actual][i].second>=0)*/
{
cout<<actual<<' '<<G[actual][i].first<<'\n';
been[G[actual][i].first]=true;
ant[G[actual][i].first]=actual;
S.push(G[actual][i].first);
}
}
}
return false;
}
void GetMin()
{
}
void Augment()
{
}
void Edmonds()
{
}
void Read()
{
f>>n>>m;
for(int i=0;i<m;i++)
{
int from, to, flow;
f>>from>>to>>flow;
G[from].push_back( mp(to,flow) );
}
}
int main()
{
Read();
return 0;
}