#include "crocodile.h"
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
bool is[100005];
vector < pair < long long , long long > > Next[100005];
vector < pair < long long , long long > > Next2[100005];
map < long long , long long > how[100005];
bool have[5][100005]={0};
priority_queue < pair < long long , pair < long long , long long > > , vector < pair < long long , pair < long long , long long > > > , greater < pair < long long , pair < long long , long long > > > > dij;
long long F(long long fa,long long here)
{
long long t;
vector < long long > tt;
if(is[here]) return 0;
for(auto i:Next2[here])
{
if(i.first!=fa)
{
t=F(here,i.first);
if(t!=-1) tt.push_back(t+i.second);
}
}
sort(tt.begin(),tt.end());
if(tt.size()>=2) return tt[1];
else return -1;
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
int i;
long long a,b,c;
for(i=0;i<M;i++)
{
Next[R[i][0]].push_back(make_pair((long long) R[i][1],(long long) L[i]));
Next[R[i][1]].push_back(make_pair((long long) R[i][0],(long long) L[i]));
how[R[i][0]][R[i][1]]=L[i];
how[R[i][1]][R[i][0]]=L[i];
}
dij.push(make_pair(0,make_pair(0,-1)));
while(!dij.empty())
{
a=dij.top().first;
b=dij.top().second.first;
c=dij.top().second.second;
dij.pop();
if(have[0][b]==0) have[0][b]=1;
else if(have[1][b]==0) have[1][b]=1;
else continue;
if(c!=-1) Next2[c].push_back(make_pair(b,how[b][c]));
for(auto i:Next[b])
{
dij.push(make_pair(i.second+a,make_pair(i.first,b)));
}
}
for(i=0;i<K;i++) is[P[i]]=1;
return (int) F(-1,0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
9708 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
9708 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
9708 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |