#include "swap.h"
#include <bits/stdc++.h>
#define ll long long
#define pl pair<ll, ll>
#define llv vector<ll>
#define pv vector<pl>
#define pb push_back
#define ppb(x, y) push_back({x, y})
#define ff first
#define ss second
#define sz size()
using namespace std;
const int NN = 2 * 1e5 + 3, MOD = 1e9 + 7;
pl u0[NN];
pv v[NN];
ll n, m, k, d, u[NN];
bool f, f1, f2, f3;
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W)
{
n = N;
m = M;
for (int i=0; i<m; i++)
{
v[V[i]].ppb(U[i], W[i]);
v[U[i]].ppb(V[i], W[i]);
k = max(k, 1ll * W[i]);
u0[i] = {W[i], V[i]};
}
sort(u0, u0 + m);
for (int i=0; i<m; i++) u[u0[i].ss] = u0[i].ss;
d = u[2];
int p = 0, q = 0;
for (int i=0; i<n; i++)
{
if (v[i].sz == 1) q++;
if (v[i].sz == 2) p++;
}
if (q == 2 && q + p == n) f = 1;
if (m == n - 1 && v[0].sz == m) f1 = 1;
f2 = 1;
for (int i=0; i<n; i++)
{
if(v[i].sz != 2)
{
f2 = 0;
break;
}
}
return ;
}
int getMinimumFuelCapacity(int X, int Y)
{
if (f) return -1;
if (f2) return k;
if (f1) return max({d, 1ll*u[X], 1ll*u[Y]});
}
Compilation message
swap.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
swap.cpp:44:28: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
44 | if (m == n - 1 && v[0].sz == m) f1 = 1;
| ~~~~~~~~^~~~
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
62 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
5004 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
3 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
5068 KB |
Output is correct |
6 |
Correct |
4 ms |
5068 KB |
Output is correct |
7 |
Correct |
4 ms |
5068 KB |
Output is correct |
8 |
Correct |
4 ms |
5012 KB |
Output is correct |
9 |
Correct |
56 ms |
14484 KB |
Output is correct |
10 |
Correct |
70 ms |
16480 KB |
Output is correct |
11 |
Correct |
67 ms |
16296 KB |
Output is correct |
12 |
Correct |
72 ms |
16912 KB |
Output is correct |
13 |
Correct |
72 ms |
17028 KB |
Output is correct |
14 |
Correct |
63 ms |
14788 KB |
Output is correct |
15 |
Correct |
128 ms |
20344 KB |
Output is correct |
16 |
Correct |
129 ms |
20080 KB |
Output is correct |
17 |
Correct |
137 ms |
20732 KB |
Output is correct |
18 |
Correct |
133 ms |
20648 KB |
Output is correct |
19 |
Correct |
65 ms |
11916 KB |
Output is correct |
20 |
Correct |
135 ms |
21872 KB |
Output is correct |
21 |
Correct |
134 ms |
21756 KB |
Output is correct |
22 |
Correct |
137 ms |
22444 KB |
Output is correct |
23 |
Correct |
135 ms |
22444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
5004 KB |
Output is correct |
3 |
Incorrect |
117 ms |
19560 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
5004 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
3 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
5068 KB |
Output is correct |
6 |
Correct |
4 ms |
5068 KB |
Output is correct |
7 |
Correct |
4 ms |
5068 KB |
Output is correct |
8 |
Correct |
4 ms |
5012 KB |
Output is correct |
9 |
Incorrect |
3 ms |
4924 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
4924 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
5004 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
3 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
5068 KB |
Output is correct |
6 |
Correct |
4 ms |
5068 KB |
Output is correct |
7 |
Correct |
4 ms |
5068 KB |
Output is correct |
8 |
Correct |
4 ms |
5012 KB |
Output is correct |
9 |
Correct |
56 ms |
14484 KB |
Output is correct |
10 |
Correct |
70 ms |
16480 KB |
Output is correct |
11 |
Correct |
67 ms |
16296 KB |
Output is correct |
12 |
Correct |
72 ms |
16912 KB |
Output is correct |
13 |
Correct |
72 ms |
17028 KB |
Output is correct |
14 |
Correct |
63 ms |
14788 KB |
Output is correct |
15 |
Correct |
128 ms |
20344 KB |
Output is correct |
16 |
Correct |
129 ms |
20080 KB |
Output is correct |
17 |
Correct |
137 ms |
20732 KB |
Output is correct |
18 |
Correct |
133 ms |
20648 KB |
Output is correct |
19 |
Incorrect |
117 ms |
19560 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
4924 KB |
Output isn't correct |