#include<bits/stdc++.h>
using namespace std;
#include "crocodile.h"
#define F first
#define S second
#define ll long long
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
int ans=0;
vector<vii> adj;
bool vis[1000000];
bool nice[1000000];
bool dfs(int s){
//cout<<s<<" ";
vis[s] = true;
if(nice[s]) return true;
//cout<<adj[s].size()<<endl;
int ind=0;
int cnt=0;
for(auto x : adj[s]){
//cout<<" "<<x.S<<" "<<vis[x.S]<<endl;
if(!vis[x.S]) cnt++;
if(cnt==2) break;
ind++;
}
//cout<<ind<<endl;
if(ind!=0 && ind<adj[s].size()){
ans+=adj[s][ind].F;
if(dfs(adj[s][ind].S)) return true;
}
return false;
}
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
adj.assign(n+1, vii());
for(int i=0;i<m;i++){
adj[r[i][0]].push_back(ii(l[i], r[i][1]));
adj[r[i][1]].push_back(ii(l[i], r[i][0]));
}
for(int i=0;i<n;i++){
sort(adj[i].begin(), adj[i].end());
}
dfs(0);
return ans;
}
Compilation message
crocodile.cpp: In function 'bool dfs(int)':
crocodile.cpp:28:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(ind!=0 && ind<adj[s].size()){
~~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |