이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "swap.h"
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 1e5 + 123;
int n;
vector<pair<int, int>> edg[MAXN];
void init(int N, int m, vector<int> U, vector<int> V, vector<int> W) {
n = N;
vector<pair<int, pair<int, int>>> edg_weight(m);
for (int i = 0; i < m; ++i) {
edg_weight[i] = {W[i], {U[i], V[i]}};
}
sort(edg_weight.begin(), edg_weight.end());
for (auto [w, e] : edg_weight) {
auto [u, v] = e;
edg[u].push_back({v, w});
edg[v].push_back({u, w});
}
}
int getMinimumFuelCapacity(int X, int Y) {
if (edg[0].size() < n - 1)
return -1;
if (edg[0].size() < 3)
return -1;
if (X == 0) {
return max(edg[0][2].second, edg[Y][0].second);
}
if (Y == 0)
return getMinimumFuelCapacity(Y, X);
return max({edg[0][2].second, edg[X][0].second, edg[Y][0].second});
}
컴파일 시 표준 에러 (stderr) 메시지
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:25:23: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
25 | if (edg[0].size() < n - 1)
| ~~~~~~~~~~~~~~^~~~~~~
# | 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... |