#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> w1;
vector<pair<int,int>> w2;
bool bambusz;
void init(int N, int M,
std::vector<int> U, std::vector<int> V, std::vector<int> W) {
if(N <= 3)bambusz = true;
w1.resize(N);
w1[0] = 0;
for(int i = 0; i < M; i++){
w1[V[i]] = W[i];
}
for(int i = 0; i < M; i++){
w2.push_back({W[i], V[i]});
}
sort(w2.begin(), w2.end());
}
int getMinimumFuelCapacity(int X, int Y) {
if(bambusz)return -1;
if(X == 0 || Y == 0){
if(X == 0)swap(X, Y);
int mx = w1[X];
int i = 0;
if(X == w2[i].second)i++;
mx = max(mx, w2[i].first);
i++;
if(X == w2[i].second)i++;
return max(mx, w2[i].first);
} else {
int i = 0;
int mx = max(w1[X], w1[Y]);
if(X == w2[i].second || Y == w2[i].second)i++;
if(X == w2[i].second || Y == w2[i].second)i++;
return max(mx, w2[i].first);
}
// int mx = 0;
// if(X != 0) mx = max(mx, w1[X]);
// if(Y != 0) mx = max(mx, w1[Y]);
// int i = 0;
// if(X == w2[i].second || Y == w2[i].second)i++;
// if(X == w2[i].second || Y == w2[i].second)i++;
// if(X == 0 || Y == 0){
// int j = i+1;
// if(X == w2[j].second || Y == w2[j].second)j++;
// if(X == w2[j].second || Y == w2[j].second)j++;
// return max(mx, max(w2[i].first, w2[j].second));
// }
// return max(mx, w2[i].first);
}
/*
4 3
0 1 1
0 2 2
0 3 3
4
1 2
1 3
0 1
3 0
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
84 ms |
8772 KB |
Output is correct |
4 |
Correct |
85 ms |
10536 KB |
Output is correct |
5 |
Correct |
88 ms |
10812 KB |
Output is correct |
6 |
Correct |
104 ms |
10532 KB |
Output is correct |
7 |
Correct |
87 ms |
10892 KB |
Output is correct |
8 |
Correct |
87 ms |
10644 KB |
Output is correct |
9 |
Correct |
85 ms |
10640 KB |
Output is correct |
10 |
Correct |
92 ms |
10624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |