#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int,int> > >adj;
vector<vector<int> >par,dis,mn;
vector<int>dep;
vector<vector<int> >mnaf;
int dfs(int cr=0,int pr=-1,int d=-1,int m=INT_MAX){
par[cr][0]=pr;
for(int i=1;i<30;i++){
if(par[cr][i-1]==-1)break;
par[cr][i]=par[par[cr][i-1]][i-1];
}
dis[cr][0]=d;
for(int i=1;i<30;i++){
if(par[cr][i-1]==-1)break;
dis[cr][i]=dis[par[cr][i-1]][i-1];
}
mn[cr][0]=m;
for(int i=1;i<30;i++){
if(par[cr][i-1]==-1)break;
mn[cr][i]=mn[par[cr][i-1]][i-1];
}
if(pr==-1)dep[cr]=0;
else dep[cr]=dep[pr]+1;
for(int i=0;i<adj[cr].size();i++){
if(adj[cr][i].first!=pr){
if(adj[cr][i].second<mnaf[cr][0]){
mnaf[cr][1]=mnaf[cr][0];
mnaf[cr][0]=adj[cr][i].second;
}else{
mnaf[cr][1]=adj[cr][i].second;
}
}
}
for(int i=0;i<adj[cr].size();i++){
if(adj[cr][i].first!=pr){
dfs(adj[cr][i].first,cr,adj[cr][i].second,(mnaf[cr][0]==adj[cr][i].second)?mnaf[cr][1]:mnaf[cr][0]);
}
}
return 0;
}
int f,mxx;
void init (int n,int m,vector<int>u,vector<int>v,vector<int>w){
f=m<n;
mxx=0;
for(int i=0;i<w.size();i++)
mxx=max(mxx,w[i]);
/**
for(int i=0;i<n;i++){
for(int j=0;j<10;j++)
cout<<mn[i][j]<<' ';
cout<<'\n';
}
*/
}
int getMinimumFuelCapacity(int x,int y){
if(f)
return -1;
return mxx;
}/**
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
init(5,4,{0,0,0,1},{1,2,3,4},{5,5,3,2});
return 0;
}*/
Compilation message
swap.cpp: In function 'int dfs(int, int, int, int)':
swap.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i=0;i<adj[cr].size();i++){
| ~^~~~~~~~~~~~~~~
swap.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i=0;i<adj[cr].size();i++){
| ~^~~~~~~~~~~~~~~
swap.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
swap.cpp:50:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int i=0;i<w.size();i++)
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
220 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
28 ms |
2120 KB |
Output is correct |
10 |
Correct |
33 ms |
2456 KB |
Output is correct |
11 |
Correct |
32 ms |
2504 KB |
Output is correct |
12 |
Correct |
38 ms |
2624 KB |
Output is correct |
13 |
Correct |
34 ms |
2620 KB |
Output is correct |
14 |
Correct |
33 ms |
2240 KB |
Output is correct |
15 |
Correct |
95 ms |
4260 KB |
Output is correct |
16 |
Correct |
94 ms |
4264 KB |
Output is correct |
17 |
Correct |
96 ms |
4384 KB |
Output is correct |
18 |
Correct |
98 ms |
4380 KB |
Output is correct |
19 |
Correct |
58 ms |
3976 KB |
Output is correct |
20 |
Correct |
94 ms |
5412 KB |
Output is correct |
21 |
Correct |
97 ms |
5672 KB |
Output is correct |
22 |
Correct |
100 ms |
5824 KB |
Output is correct |
23 |
Correct |
99 ms |
5792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
89 ms |
4208 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
220 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
220 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
28 ms |
2120 KB |
Output is correct |
10 |
Correct |
33 ms |
2456 KB |
Output is correct |
11 |
Correct |
32 ms |
2504 KB |
Output is correct |
12 |
Correct |
38 ms |
2624 KB |
Output is correct |
13 |
Correct |
34 ms |
2620 KB |
Output is correct |
14 |
Correct |
33 ms |
2240 KB |
Output is correct |
15 |
Correct |
95 ms |
4260 KB |
Output is correct |
16 |
Correct |
94 ms |
4264 KB |
Output is correct |
17 |
Correct |
96 ms |
4384 KB |
Output is correct |
18 |
Correct |
98 ms |
4380 KB |
Output is correct |
19 |
Incorrect |
89 ms |
4208 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |