이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "swap.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
#define L(i, j, k) for (int i = (j); i <= k; i++)
#define R(i, j, k) for (int i = (j); i >= k; i--)
const int nax = 100050;
int n, m, to[nax];
pair<int, int> T[nax];
void init(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
n = N, m = M;
L(i, 0, M - 1){
T[i] = make_pair(W[i], V[i]);
to[V[i]] = W[i];
}
sort(T + 1, T + 1 + M);
}
int getMinimumFuelCapacity(int X, int Y) {
if (n <= 3) return -1;
if (X == 0) {
int count = 0, ans = to[Y];
L(i, 0, 2) {
// 1: we want to find 0 -> A (that is not Y)
// 2: Y -> 0 -> B,
// 1: A -> 0 -> Y
// 2: B -> 0
// we need at most 2 nodes that is not Y
if (T[i].second == Y) continue;
count++;
ans = max(ans, T[i].first);
if (count >= 2) break;
}
return ans;
}
else {
// 1: X -> 0 -> A
// 2: Y -> 0 -> X
// 1: A -> 0 -> Y
// we need at most one node that is not X and not Y
L(i, 0, 2) {
if (T[i].second != X && T[i].second != Y) {
return max({T[i].first, to[X], to[Y]});
}
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
50 | }
| ^
# | 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... |