Submission #597270

# Submission time Handle Problem Language Result Execution time Memory
597270 2022-07-15T20:17:12 Z Ozy Swapping Cities (APIO20_swap) C++17
7 / 100
89 ms 11916 KB
#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "

#define MAX 100000
#define u second.first
#define v second.second
#define w first

lli peso[MAX+2],a,b,c,n,m;
vector<pair<lli,lli> > orden;

void init(int N, int M,std::vector<int> U, std::vector<int> V, std::vector<int> W) {
    n = N;
    m = M;

    rep(i,0,m-1) {
        peso[V[i]+1] = W[i];
        orden.push_back({W[i],V[i]+1});
    }
    sort(orden.begin(), orden.end());
}

int getMinimumFuelCapacity(int X, int Y) {
    X++;
    Y++;

    if (n < 4) return -1;

    if (Y < X) swap(Y,X);

    c = peso[Y];
    if (X == 1) {
        if (orden[0].second == Y) X = orden[1].second;
        else X = orden[0].second;
    }
    b = peso[X];

    for (auto act : orden) {
        if (act.second == Y || act.second == X) continue;
        a = act.first;
        break;
    }

    a = max(a,b);
    a = max(a,c);
    return a;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 83 ms 7796 KB Output is correct
4 Correct 87 ms 7928 KB Output is correct
5 Correct 86 ms 8148 KB Output is correct
6 Correct 85 ms 11548 KB Output is correct
7 Correct 88 ms 11916 KB Output is correct
8 Correct 86 ms 11640 KB Output is correct
9 Correct 89 ms 11708 KB Output is correct
10 Correct 85 ms 11624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -