#include "crocodile.h"
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int vis[MAXN],dis[MAXN][2];
vector<PII>adj[MAXN];
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]){
for(int i=0;i<m;i++){
int u=R[i][0],v=R[i][1],w=L[i];
adj[u].pb(mp(v,w));
adj[v].pb(mp(u,w));
}
priority_queue<PII,vector<PII>,greater<PII> >q;
memset(dis,127,sizeof dis);
for(int i=0;i<k;i++){
int x=P[i];q.push(mp(0,x));
dis[x][0]=0;vis[x]++;
}
while(q.size()){
PII go=q.top();
int nd=go.ss,val=go.ff;
q.pop();vis[nd]++;
if(vis[nd]!=2) continue;
if(nd==0 and vis[nd]==2)
return dis[0][1];
tr(it,adj[nd]){
int x=it->ff;
int way=val+it->ss;
if(vis[x]<2 and way<dis[x][1]){
dis[x][1]=way;
if(dis[x][1]<dis[x][0])
swap(dis[x][1],dis[x][0]);
q.push(mp(way,x));
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3436 KB |
Output is correct |
2 |
Correct |
3 ms |
3436 KB |
Output is correct |
3 |
Correct |
3 ms |
3436 KB |
Output is correct |
4 |
Correct |
3 ms |
3564 KB |
Output is correct |
5 |
Correct |
3 ms |
3564 KB |
Output is correct |
6 |
Correct |
3 ms |
3564 KB |
Output is correct |
7 |
Correct |
3 ms |
3564 KB |
Output is correct |
8 |
Correct |
4 ms |
3564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3436 KB |
Output is correct |
2 |
Correct |
3 ms |
3436 KB |
Output is correct |
3 |
Correct |
3 ms |
3436 KB |
Output is correct |
4 |
Correct |
3 ms |
3564 KB |
Output is correct |
5 |
Correct |
3 ms |
3564 KB |
Output is correct |
6 |
Correct |
3 ms |
3564 KB |
Output is correct |
7 |
Correct |
3 ms |
3564 KB |
Output is correct |
8 |
Correct |
4 ms |
3564 KB |
Output is correct |
9 |
Correct |
5 ms |
3692 KB |
Output is correct |
10 |
Correct |
3 ms |
3436 KB |
Output is correct |
11 |
Correct |
3 ms |
3564 KB |
Output is correct |
12 |
Correct |
6 ms |
3948 KB |
Output is correct |
13 |
Correct |
5 ms |
3948 KB |
Output is correct |
14 |
Correct |
3 ms |
3564 KB |
Output is correct |
15 |
Correct |
3 ms |
3564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3436 KB |
Output is correct |
2 |
Correct |
3 ms |
3436 KB |
Output is correct |
3 |
Correct |
3 ms |
3436 KB |
Output is correct |
4 |
Correct |
3 ms |
3564 KB |
Output is correct |
5 |
Correct |
3 ms |
3564 KB |
Output is correct |
6 |
Correct |
3 ms |
3564 KB |
Output is correct |
7 |
Correct |
3 ms |
3564 KB |
Output is correct |
8 |
Correct |
4 ms |
3564 KB |
Output is correct |
9 |
Correct |
5 ms |
3692 KB |
Output is correct |
10 |
Correct |
3 ms |
3436 KB |
Output is correct |
11 |
Correct |
3 ms |
3564 KB |
Output is correct |
12 |
Correct |
6 ms |
3948 KB |
Output is correct |
13 |
Correct |
5 ms |
3948 KB |
Output is correct |
14 |
Correct |
3 ms |
3564 KB |
Output is correct |
15 |
Correct |
3 ms |
3564 KB |
Output is correct |
16 |
Correct |
496 ms |
59068 KB |
Output is correct |
17 |
Correct |
81 ms |
14188 KB |
Output is correct |
18 |
Correct |
97 ms |
15596 KB |
Output is correct |
19 |
Correct |
593 ms |
61544 KB |
Output is correct |
20 |
Correct |
304 ms |
50284 KB |
Output is correct |
21 |
Correct |
43 ms |
8428 KB |
Output is correct |
22 |
Correct |
329 ms |
46700 KB |
Output is correct |