9332 | 2024-02-20 14:46:45 | AGergo | Hálózati átvitel | cpp17 | Compilation error |
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> graf; //graf[a][b] -> a b közti sebesség
//vector<bool> used; // használt-e már adott pont
vector<vector<int>> ut; // [a][b] -> K-ból a-ba menõ út b lépésben legnagyobb gyorsasága
vector<vector<int>> available; //osszes hely avoha lehet menni (adott vektorból)
int maxLepes;
bejar(int id,int speed, int steps)
{
steps++;
if(steps <= maxLepes)
{
for(int i: available[id])
{
int spd = graf[id][i];
if(speed > spd)
{
//speed = spd;ssss
}
else
{
spd = speed;
}
if(spd > ut[i][steps])
{
ut[i][steps] = spd;
}
//cout << id << "->" << i << ": " << spd << ":" << speed << endl;
bejar(i,spd,steps);
}
}
}
int main()
{
iostream::sync_with_stdio(0);cin.tie(0);
//dijkstra csak minden utat eltárolsz
int csomo,vonal,koz;
cin >> csomo >> vonal >> koz >> maxLepes;
graf.resize(csomo+1,vector<int>(csomo+1));
available.resize(csomo+1);
int p1,p2,v;
for(int i = 0; i < vonal; i++)
{
cin >> p1 >> p2 >> v;
graf[p1][p2] = v;
graf[p2][p1] = v;
available[p1].resize(available[p1].size()+1);
available[p1][available[p1].size()-1] = p2;
available[p2].resize(available[p2].size()+1);
available[p2][available[p2].size()-1] = p1;
}
//used.resize(csomo+1,false);
ut.resize(csomo+1,vector<int>(maxLepes+1,-1));
bejar(koz,100001,0);
int highest;
//cout << "-----------------------\n";
for(int i = 1;i <= csomo;i++)
{
if(i == koz)
{
cout << "0\n";
}
else
{
highest = 0;
for(int x: ut[i])
{
//cout << x << ":";
if( x > highest )
{
highest = x;
}
}
cout << highest <<"\n";
}
}
}
exit status 1
main.cpp:11:1: error: ISO C++ forbids declaration of 'bejar' with no type [-fpermissive]
11 | bejar(int id,int speed, int steps)
| ^~~~~
main.cpp: In function 'int bejar(int, int, int)':
main.cpp:36:1: warning: no return statement in function returning non-void [-Wreturn-type]
36 | }
| ^
Exited with error status 1