#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
#define endl "\n"
const int mxn=1000+5;
ll isexit[mxn],col[mxn],n,m,arr[mxn];
vector<pll>vt[mxn];
ll funk(int u,ll sum,vector<int>color){
if(isexit[u]){
return sum;
}
vector<int>v;
color[u]=1;
for(int i=0;i<vt[u].size();i++){
if(!color[vt[u][i].F]){
int q=funk(vt[u][i].F,sum+vt[u][i].S,color);
if(v.size()<2){
v.pb(q);
sort(all(v));
}
else{
if(q<v.back()){
v.pop_back();
v.pb(q);
sort(all(v));
}
}
}
}
return v[1];
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
n=N,m=M;
for(int i=0;i<m;i++){
vt[R[i][0]].pb({R[i][1],L[i]});
vt[R[i][1]].pb({R[i][0],L[i]});
}
for(int i=0;i<K;i++){
isexit[P[i]]=1;
}
vector<int>vv;
for(int i=0;i<=n;i++){
vv.pb(0);
arr[i]=INF;
}
ll ans=funk(0,0,vv);
return ans;
}
Compilation message
crocodile.cpp: In function 'long long int funk(int, long long int, std::vector<int>)':
crocodile.cpp:25:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for(int i=0;i<vt[u].size();i++){
| ~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
972 KB |
Output is correct |
7 |
Correct |
3 ms |
1996 KB |
Output is correct |
8 |
Correct |
2 ms |
2380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
972 KB |
Output is correct |
7 |
Correct |
3 ms |
1996 KB |
Output is correct |
8 |
Correct |
2 ms |
2380 KB |
Output is correct |
9 |
Execution timed out |
2087 ms |
844 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
972 KB |
Output is correct |
7 |
Correct |
3 ms |
1996 KB |
Output is correct |
8 |
Correct |
2 ms |
2380 KB |
Output is correct |
9 |
Execution timed out |
2087 ms |
844 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |