#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;
int isexit[mxn],col[mxn],n,m;
vector<pll>vt[mxn];
ll funk(int u,ll sum,int cut,vector<int>color){
color[u]=1;
if(isexit[u]){
return sum;
}
ll ans=0;
if(cut==-1){
for(int i=0;i<vt[u].size();i++){
if(!color[vt[u][i].F]){
ans=max(ans,funk(u,sum,i,color));
}
}
return ans;
}
else{
ll x=INF;
for(int i=0;i<vt[u].size();i++){
if(i!=cut&&!color[vt[u][i].F]){
x=min(funk(vt[u][i].F,sum+vt[u][i].S,-1,color),x);
}
}
return x;
}
}
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);
}
ll ans=funk(0,0,-1,vv);
return ans;
}
Compilation message
crocodile.cpp: In function 'long long int funk(int, long long int, int, std::vector<int>)':
crocodile.cpp:26:16: 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]
26 | for(int i=0;i<vt[u].size();i++){
| ~^~~~~~~~~~~~~
crocodile.cpp:35:16: 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]
35 | for(int i=0;i<vt[u].size();i++){
| ~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
352 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
7 ms |
496 KB |
Output is correct |
5 |
Correct |
104 ms |
428 KB |
Output is correct |
6 |
Execution timed out |
2062 ms |
1580 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
352 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
7 ms |
496 KB |
Output is correct |
5 |
Correct |
104 ms |
428 KB |
Output is correct |
6 |
Execution timed out |
2062 ms |
1580 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
352 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
7 ms |
496 KB |
Output is correct |
5 |
Correct |
104 ms |
428 KB |
Output is correct |
6 |
Execution timed out |
2062 ms |
1580 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |