답안 #402872

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
402872 2021-05-12T13:04:20 Z Collypso 자매 도시 (APIO20_swap) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
//#define endl '\n'
//#define int ll

using namespace std;

vt<pair<int, int>> v;
vt<int> weight;

void init(int N, int M, vt<int> U, vt<int> V, vt<int> W)
{
    weight.resize(N);
    for(int i = 0; i < M; i++) v.pb({W[i], V[i]}), weight[V[i]] = W[i];
    sort(all(weight));
}

int getMinimumFuelCapacity(int X, int Y)
{
    if (sz(v) == 2) return -1;
    if (min(X, Y) == min(v[0].second, v[1].second) &&
        max(X, Y) == max(v[0].second, v[1].second)) return v[2].second;
    return max(weight[X], weight[Y]);
}

/**
main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    freopen("input.txt", "r", stdin);
    int N, M, Q;
    cin >> N >> M;
    vt<int> U, V, W;
    for(int i = 0; i < M; i++) cin >> U[i] >> V[i] >> W[i];
    init(N, M, U, V, W);
    cin >> Q;
    while(Q--)
    {
        int X, Y;
        cin >> X >> Y;
        cout << getMinimumFuelCapacity(X, Y) << endl;
    }

}
/**/

Compilation message

swap.cpp:52:1: warning: "/*" within comment [-Wcomment]
   52 | /**/
      |
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -