#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
typedef long long ll;
//#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<pair<int,int> >v[100010];
set<int> win;
int dfs(int pos,int prec){
if(win.find(pos)!=win.end())return 0;
vector<int> s;
for(auto k:v[pos]){
if(k.first==prec)continue;
s.push_back(dfs(k.first,pos)+k.second);
}
sort(s.begin(),s.end());
s.push_back(1e12);
s.push_back(1e12);
return s[1];
}
int travel_plan(int N,int M,int R[][2],int L[],int K,int P[]){
for(int i=0;i<M;i++){
v[R[i][0]].push_back({R[i][1],L[i]});
v[R[i][1]].push_back({R[i][0],L[i]});
}
for(int i=0;i<K;i++)win.insert(P[i]);
return dfs(0,-1);
}
Compilation message
crocodile.cpp: In function 'int dfs(int, int)':
crocodile.cpp:18:19: warning: overflow in implicit constant conversion [-Woverflow]
s.push_back(1e12);
^
crocodile.cpp:19:19: warning: overflow in implicit constant conversion [-Woverflow]
s.push_back(1e12);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2688 KB |
Output is correct |
3 |
Correct |
2 ms |
2688 KB |
Output is correct |
4 |
Correct |
3 ms |
2816 KB |
Output is correct |
5 |
Correct |
3 ms |
2816 KB |
Output is correct |
6 |
Correct |
2 ms |
2816 KB |
Output is correct |
7 |
Correct |
3 ms |
2816 KB |
Output is correct |
8 |
Correct |
3 ms |
2816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2688 KB |
Output is correct |
3 |
Correct |
2 ms |
2688 KB |
Output is correct |
4 |
Correct |
3 ms |
2816 KB |
Output is correct |
5 |
Correct |
3 ms |
2816 KB |
Output is correct |
6 |
Correct |
2 ms |
2816 KB |
Output is correct |
7 |
Correct |
3 ms |
2816 KB |
Output is correct |
8 |
Correct |
3 ms |
2816 KB |
Output is correct |
9 |
Runtime error |
173 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2688 KB |
Output is correct |
3 |
Correct |
2 ms |
2688 KB |
Output is correct |
4 |
Correct |
3 ms |
2816 KB |
Output is correct |
5 |
Correct |
3 ms |
2816 KB |
Output is correct |
6 |
Correct |
2 ms |
2816 KB |
Output is correct |
7 |
Correct |
3 ms |
2816 KB |
Output is correct |
8 |
Correct |
3 ms |
2816 KB |
Output is correct |
9 |
Runtime error |
173 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Halted |
0 ms |
0 KB |
- |