Submission #402900

# Submission time Handle Problem Language Result Execution time Memory
402900 2021-05-12T13:22:49 Z Collypso Swapping Cities (APIO20_swap) C++17
7 / 100
143 ms 10960 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(v));
    weight[0] = v[2].first;
}

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].first;
    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(M), V(M), W(M);
    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:53:1: warning: "/*" within comment [-Wcomment]
   53 | /**/
      |
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 105 ms 6792 KB Output is correct
4 Correct 108 ms 10564 KB Output is correct
5 Correct 123 ms 10960 KB Output is correct
6 Correct 134 ms 10624 KB Output is correct
7 Correct 143 ms 10800 KB Output is correct
8 Correct 121 ms 10612 KB Output is correct
9 Correct 131 ms 10624 KB Output is correct
10 Correct 112 ms 10640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -