#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;
int a1[100005],a2[100005],a3[100005],ma[100005],sma[100005],in[100005],used[100005];
vector<cell>v[100005];
void find_ma(int beg)
{
used[beg]=1;
int w;
for(int i=0;i<v[beg].size();i++)
{
w=v[beg][i].to;
if(!used[w])
{
find_ma(w);
if(ma[beg]<ma[w]+v[beg][i].cost)
{
sma[beg]=ma[beg];
ma[beg]=ma[w]+v[beg][i].cost;
in[beg]=w;
}
else if(sma[beg]<ma[w]+v[beg][i].cost)
{
sma[beg]=ma[w]+v[beg][i].cost;
}
}
}
}
int travelTime(int n,int m,int l,int a1[],int a2[],int a3[])
//void read()
{
//cin>>n>>m>>l;
cell h;
for(int i=1;i<=m;i++)
{
//cin>>a1[i]>>a2[i]>>a3[i];
h.to=a1[i];
h.cost=a3[i];
v[a2[i]].push_back(h);
h.to=a2[i];
v[a1[i]].push_back(h);
}
for(int i=1;i<=n;i++)
{
if(!used[i])
{
find_ma(i);
}
}
int aa=0;
for(int i=1;i<=n;i++)
{
aa=max(aa,ma[i]+sma[i]);
}
//cout<<aa<<endl;
return aa;
}
/*int main()
{
speed();
read();
return 0;
}
*/
Compilation message
dreaming.cpp: In function 'void find_ma(int)':
dreaming.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<cell>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(int i=0;i<v[beg].size();i++)
| ~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
12884 KB |
Output is correct |
2 |
Correct |
30 ms |
13652 KB |
Output is correct |
3 |
Correct |
19 ms |
9612 KB |
Output is correct |
4 |
Correct |
5 ms |
5468 KB |
Output is correct |
5 |
Correct |
4 ms |
4956 KB |
Output is correct |
6 |
Incorrect |
8 ms |
6236 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
12884 KB |
Output is correct |
2 |
Correct |
30 ms |
13652 KB |
Output is correct |
3 |
Correct |
19 ms |
9612 KB |
Output is correct |
4 |
Correct |
5 ms |
5468 KB |
Output is correct |
5 |
Correct |
4 ms |
4956 KB |
Output is correct |
6 |
Incorrect |
8 ms |
6236 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
7400 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
12884 KB |
Output is correct |
2 |
Correct |
30 ms |
13652 KB |
Output is correct |
3 |
Correct |
19 ms |
9612 KB |
Output is correct |
4 |
Correct |
5 ms |
5468 KB |
Output is correct |
5 |
Correct |
4 ms |
4956 KB |
Output is correct |
6 |
Incorrect |
8 ms |
6236 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |