Pagini recente » Cod sursa (job #2097131) | Cod sursa (job #1775336) | Cod sursa (job #1335451) | Borderou de evaluare (job #2051290) | Cod sursa (job #1840444)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("pitici.in");
ofstream fout("pitici.out");
const int MAXN = 1030;
const int MAXC = 1005;
int N, M, K;
int ns[MAXN*MAXC];
vector<vector<pair<int, int>>> G;
void Read();
void DFS( int nod, int c );
void Write();
int main()
{
Read();
DFS(N, 0);
Write();
fin.close();
fout.close();
return 0;
}
void Read()
{
int i, x, y, w;
fin >> N >> M >> K;
G.resize(N + 1);
while ( M-- )
{
fin >> x >> y >> w;
G[y].push_back({x, w});
}
}
void DFS( int nod, int c )
{
if ( nod == 1 )
{
ns[c]++;
return;
}
for ( const auto& x : G[nod] )
DFS(x.first, c + x.second);
}
void Write()
{
int i;
for ( i = 0; i < MAXC*MAXN && K; ++i )
{
while ( ns[i] )
{
fout << i << ' ';
K--, ns[i]--;
}
}
}