ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1450. Russian Pipelines

Posted by Manflack 7 Jul 2017 00:10
#include <iostream>
#include <vector>
#include <queue>
#define INF (1<<29)
using namespace std;

struct Arista
{
int hasta,costo;
};

Arista armar(int h,int c)
{
Arista ar;
ar.hasta=h;
ar.costo=c;
return ar;
}

struct Grafo
{
int suma=0;

vector <int> dist;
bool encontro=false;

int nodos,aristas;
int S,F;

void leer()
{
cin >> nodos >> aristas;
dist.resize(nodos+1,INF);

int desde,hasta,costo;
for(int c=0; c<aristas; c++)
{
cin >> desde >> hasta >> costo;
}

cin >> S >> F;
dist[S]=0;
}

{

{
{
dist[vecino]=dist[nodo]+costo;
bdfs(vecino,nodo);
}
}
}

void start()
{
if(dist[F]<INF) cout << dist[F];
else cout << "No solution";
}

};

int main()
{
Grafo g;
g.leer();
g.bdfs(g.S,-1);
g.start();
cout << endl;
return 0;
}

BFS+DFS
Some test, guys?