#include <time.h>
#include <cstdlib>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <set>
#include <iterator>
#include <deque>
#include <queue>
#include <sstream>
#include <array>
#include <string>
#include <tuple>
#include <chrono>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <list>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>
#include "swap.h"
#include <cassert>
#include <cstdio>
using namespace std;
vector<pair<int, int>> g[200005];
pair<int, int> p[200005];
map<pair<int, int>, int> mp, pos;
set<pair<int, int>> st;
int x, y, mx;
void init(int N, int M,
std::vector<int> U, std::vector<int> V, std::vector<int> W) {
x = N;
y = M;
for(int i = 0; i < M; i++){
int a = U[i] + 1, b = V[i] + 1, c = W[i];
g[a].push_back({b, c});
g[b].push_back({a, c});
mp[{a, b}] = c;
mp[{b, a}] = c;
pos[{a, b}] = i + 1;
pos[{b, a}] = i + 1;
st.insert({c, i + 1});
}
}
int getMinimumFuelCapacity(int X, int Y) {
X++;
Y++;
if(x <= 3)
return -1;
int mx = 0;
if(X != 1) mx = mp[{1, X}];
if(Y != 1) mx = max(mx, mp[{1, Y}]);
if(X != 1) st.erase({mp[{1, X}], pos[{1, X}]});
if(Y != 1) st.erase({mp[{1, Y}], pos[{1, Y}]});
pair<int, int> p = *st.begin();
st.erase(st.begin());
if(X != 1 && Y != 1){
st.insert(p);
if(X != 1) st.insert({mp[{1, X}], pos[{1, X}]});
if(Y != 1) st.insert({mp[{1, Y}], pos[{1, Y}]});
return max(mx, p.first);
}
else{
pair<int, int> p1 = *st.begin();
st.insert(p1);
st.insert(p);
if(X != 1) st.insert({mp[{1, X}], pos[{1, X}]});
if(Y != 1) st.insert({mp[{1, Y}], pos[{1, Y}]});
return max({mx, p.first, p1.first});
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Incorrect |
4 ms |
6592 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
1070 ms |
43492 KB |
Output is correct |
4 |
Correct |
1101 ms |
45276 KB |
Output is correct |
5 |
Correct |
1077 ms |
44320 KB |
Output is correct |
6 |
Correct |
1014 ms |
45108 KB |
Output is correct |
7 |
Correct |
1138 ms |
44872 KB |
Output is correct |
8 |
Correct |
1098 ms |
43232 KB |
Output is correct |
9 |
Correct |
1100 ms |
44616 KB |
Output is correct |
10 |
Correct |
1079 ms |
42872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Incorrect |
4 ms |
6592 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Incorrect |
4 ms |
6592 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Incorrect |
4 ms |
6592 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Incorrect |
4 ms |
6592 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |