#include "swap.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int ans;
vector<pair<int,int> >vp;
int fromzerotoX[100001];
int n , m;
int closedcircle=1 , issubtask1=1;
vector<int>adj[100001];
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
n=N;
m=M;
for(int i = 0 ; i < V.size() ; i++)
{
adj[V[i]].push_back(U[i]);
adj[U[i]].push_back(V[i]);
fromzerotoX[V[i]]=W[i];
if(U[i]!=0)issubtask1=0;
vp.push_back({W[i], V[i]});
}
ans=*max_element(W.begin() , W.end());
sort(vp.begin() , vp.end());
for(int i = 0 ; i < n ; i++)
{
if(adj[i].size()!=2)
{
closedcircle=0;
break;
}
}
}
int getMinimumFuelCapacity(int X, int Y){
if(!issubtask1)
{
if(closedcircle)
{
return ans;
}
return -1;
}
if(n<4)return -1;
int x=X , y=Y , out=0;
if(x>y)
{
swap(x,y);
}
if(x==0)
{
int c=0;
out=max(out , fromzerotoX[y]);
for(auto u :vp )
{
if(u.second!=y)
{
out=max(out , u.first);
c++;
}
if(c==2)
break;
}
return out;
}
out=max( fromzerotoX[x] , fromzerotoX[y]);
for(auto u :vp )
{
if(u.second!=y&&u.second!=x)
{
out=max(out , u.first);
break;
}
}
return out;
}
Compilation message
swap.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
swap.cpp:14:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for(int i = 0 ; i < V.size() ; i++)
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
2 ms |
2764 KB |
Output is correct |
5 |
Correct |
2 ms |
2636 KB |
Output is correct |
6 |
Correct |
2 ms |
2636 KB |
Output is correct |
7 |
Correct |
3 ms |
2636 KB |
Output is correct |
8 |
Correct |
3 ms |
2636 KB |
Output is correct |
9 |
Correct |
53 ms |
9148 KB |
Output is correct |
10 |
Correct |
69 ms |
10360 KB |
Output is correct |
11 |
Correct |
65 ms |
10212 KB |
Output is correct |
12 |
Correct |
69 ms |
10700 KB |
Output is correct |
13 |
Correct |
88 ms |
10940 KB |
Output is correct |
14 |
Correct |
59 ms |
9564 KB |
Output is correct |
15 |
Correct |
132 ms |
13312 KB |
Output is correct |
16 |
Correct |
151 ms |
13096 KB |
Output is correct |
17 |
Correct |
132 ms |
13544 KB |
Output is correct |
18 |
Correct |
133 ms |
13600 KB |
Output is correct |
19 |
Correct |
65 ms |
8500 KB |
Output is correct |
20 |
Correct |
132 ms |
13568 KB |
Output is correct |
21 |
Correct |
135 ms |
13700 KB |
Output is correct |
22 |
Correct |
137 ms |
14004 KB |
Output is correct |
23 |
Correct |
141 ms |
13932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
122 ms |
15060 KB |
Output is correct |
4 |
Correct |
121 ms |
14240 KB |
Output is correct |
5 |
Correct |
125 ms |
14280 KB |
Output is correct |
6 |
Correct |
121 ms |
14072 KB |
Output is correct |
7 |
Correct |
128 ms |
14304 KB |
Output is correct |
8 |
Correct |
120 ms |
14044 KB |
Output is correct |
9 |
Correct |
125 ms |
14128 KB |
Output is correct |
10 |
Correct |
120 ms |
14044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
2 ms |
2764 KB |
Output is correct |
5 |
Correct |
2 ms |
2636 KB |
Output is correct |
6 |
Correct |
2 ms |
2636 KB |
Output is correct |
7 |
Correct |
3 ms |
2636 KB |
Output is correct |
8 |
Correct |
3 ms |
2636 KB |
Output is correct |
9 |
Incorrect |
3 ms |
2636 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2636 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
2 ms |
2764 KB |
Output is correct |
5 |
Correct |
2 ms |
2636 KB |
Output is correct |
6 |
Correct |
2 ms |
2636 KB |
Output is correct |
7 |
Correct |
3 ms |
2636 KB |
Output is correct |
8 |
Correct |
3 ms |
2636 KB |
Output is correct |
9 |
Correct |
53 ms |
9148 KB |
Output is correct |
10 |
Correct |
69 ms |
10360 KB |
Output is correct |
11 |
Correct |
65 ms |
10212 KB |
Output is correct |
12 |
Correct |
69 ms |
10700 KB |
Output is correct |
13 |
Correct |
88 ms |
10940 KB |
Output is correct |
14 |
Correct |
59 ms |
9564 KB |
Output is correct |
15 |
Correct |
132 ms |
13312 KB |
Output is correct |
16 |
Correct |
151 ms |
13096 KB |
Output is correct |
17 |
Correct |
132 ms |
13544 KB |
Output is correct |
18 |
Correct |
133 ms |
13600 KB |
Output is correct |
19 |
Correct |
122 ms |
15060 KB |
Output is correct |
20 |
Correct |
121 ms |
14240 KB |
Output is correct |
21 |
Correct |
125 ms |
14280 KB |
Output is correct |
22 |
Correct |
121 ms |
14072 KB |
Output is correct |
23 |
Correct |
128 ms |
14304 KB |
Output is correct |
24 |
Correct |
120 ms |
14044 KB |
Output is correct |
25 |
Correct |
125 ms |
14128 KB |
Output is correct |
26 |
Correct |
120 ms |
14044 KB |
Output is correct |
27 |
Incorrect |
3 ms |
2636 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2636 KB |
Output isn't correct |