#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
#define pb push_back
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define fi first
#define se second
int const n=1e5+3;
bitset<n> colored;
vpi adj[n];
int to[n];
pair<int,pii>cnt[n];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
F0R(i,N)
{
cnt[i].fi=0;
cnt[i].se.fi=2e9;
cnt[i].se.se=2e9;
}
vi nw;
F0R(i,K)
{
colored[P[i]]=1;
to[P[i]]=0;
nw.pb(P[i]);
}
F0R(i,M)
{
int u=R[i][0];
int v=R[i][1];
adj[u].pb({v,L[i]});
adj[v].pb({u,L[i]});
}
while(!colored[0])
{
trav(e,nw)
{
trav(chi,adj[e])
{
if(colored[chi.fi])continue;
++cnt[chi.fi].fi;
int cand = to[e]+chi.se;
if(cand < cnt[chi.fi].se.fi)
{
cnt[chi.fi].se.se = cnt[chi.fi].se.fi;
cnt[chi.fi].se.fi = cand;
}
else
{
cnt[chi.fi].se.se = min(cnt[chi.fi].se.se,cand);
}
}
}
nw.clear();
int rec = 1e9;
F0R(i,N)
{
if(colored[i])continue;
if(cnt[i].fi>=2)
{
if(cnt[i].se.se<=rec)
{
if(cnt[i].se.se<rec)
{
nw.clear();
}
rec=cnt[i].se.se;
nw.pb(i);
}
}
}
trav(e,nw)
{
to[e]=rec;
colored[e]=1;
}
}
return (int)to[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
3 ms |
2636 KB |
Output is correct |
5 |
Correct |
4 ms |
2636 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2636 KB |
Output is correct |
8 |
Correct |
5 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
3 ms |
2636 KB |
Output is correct |
5 |
Correct |
4 ms |
2636 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2636 KB |
Output is correct |
8 |
Correct |
5 ms |
2636 KB |
Output is correct |
9 |
Correct |
4 ms |
2892 KB |
Output is correct |
10 |
Correct |
2 ms |
2636 KB |
Output is correct |
11 |
Correct |
3 ms |
2764 KB |
Output is correct |
12 |
Correct |
6 ms |
3020 KB |
Output is correct |
13 |
Correct |
5 ms |
2992 KB |
Output is correct |
14 |
Correct |
2 ms |
2636 KB |
Output is correct |
15 |
Correct |
4 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
3 ms |
2636 KB |
Output is correct |
5 |
Correct |
4 ms |
2636 KB |
Output is correct |
6 |
Correct |
2 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2636 KB |
Output is correct |
8 |
Correct |
5 ms |
2636 KB |
Output is correct |
9 |
Correct |
4 ms |
2892 KB |
Output is correct |
10 |
Correct |
2 ms |
2636 KB |
Output is correct |
11 |
Correct |
3 ms |
2764 KB |
Output is correct |
12 |
Correct |
6 ms |
3020 KB |
Output is correct |
13 |
Correct |
5 ms |
2992 KB |
Output is correct |
14 |
Correct |
2 ms |
2636 KB |
Output is correct |
15 |
Correct |
4 ms |
2636 KB |
Output is correct |
16 |
Correct |
1182 ms |
40376 KB |
Output is correct |
17 |
Execution timed out |
2008 ms |
14176 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |