이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int nax = 100005;
int N, M;
vector<pair<int, pair<int, int>>> edges; // (W, (U, V))
int to[nax];
void init(int _N, int _M, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
N = _N; M = _M;
for (int i = 0; i < M; i++) {
edges.push_back(make_pair(W[i], make_pair(U[i], V[i])));
to[V[i]] = W[i];
}
sort(edges.begin(), edges.end());
}
int getMinimumFuelCapacity(int X, int Y) {
if (N <= 3) return -1;
if (X > Y) swap(X, Y);
if (X == 0) {
int cnt = 0, mx = to[Y];
for (int i = 0; i < M; i++) {
if (edges[i].second.second != Y) {
cnt++;
mx = max(mx, edges[i].first);
if (cnt >= 2) return mx;
}
}
}
else {
for (int i = 0; i < M; i++) {
if (edges[i].second.first != X && edges[i].second.second != Y) {
return max({to[X], to[Y], edges[i].first});
}
}
}
}
// #include "grader.cpp"
컴파일 시 표준 에러 (stderr) 메시지
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
40 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |