#include<bits/stdc++.h>
#include "dreaming.h"
using namespace std;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
struct cell
{
int to,cost;
};
int n,m,l,A[100005],B[100005],C[100005],used[100005],sum[100005],le[10];
vector<cell>v[100005];
void find_sum(int beg,int lead,int num)
{
used[beg]=1;
int w;
if(v[beg].size()==1)le[num]=beg;
for(int i=0;i<(int)(v[beg].size());i++)
{
w=v[beg][i].to;
if(!used[w])
{
find_sum(w,lead,num);
sum[lead]+=v[beg][i].cost;
}
}
}
int travelTime(int n,int m,int l,int A[],int B[],int C[])
//void read()
{
//cin>>n>>m>>l;
cell h;
for(int i=1;i<=m;i++)
{
//cin>>A[i]>>B[i]>>C[i];
A[i]++;
B[i]++;
h.to=A[i];
h.cost=C[i];
v[B[i]].push_back(h);
h.to=B[i];
v[A[i]].push_back(h);
}
int br=0;
for(int i=1;i<=n;i++)
{
if(!used[i])
{
br++;
find_sum(i,i,br);
}
}
memset(used,0,sizeof(used));
int aa=0;
for(int i=1;i<=n;i++)
{
aa=max(aa,sum[i]);
}
cout<<aa<<endl;
}
/*int main()
{
speed();
read();
return 0;
}
*/
Compilation message
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:63:1: warning: no return statement in function returning non-void [-Wreturn-type]
63 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1016 ms |
11508 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1060 ms |
5512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1016 ms |
11508 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1014 ms |
7632 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1060 ms |
5512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1016 ms |
11508 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |