Submission #747430

# Submission time Handle Problem Language Result Execution time Memory
747430 2023-05-24T07:37:51 Z vjudge1 Swapping Cities (APIO20_swap) C++17
0 / 100
101 ms 6760 KB
#include "swap.h"

#include <bits/stdc++.h>

using namespace std;

vector<int> w1;
vector<pair<int,int>> w2;
bool bambusz;

void init(int N, int M,
    std::vector<int> U, std::vector<int> V, std::vector<int> W) {
    if(N <= 3)bambusz = true;
    w1.resize(N);
    w1[0] = 0;
    for(int i = 0; i < M; i++){
        w1[V[i]] = W[i];
    }
    for(int i = 0; i < M; i++){
        w2.push_back({W[i], V[i]});
    }
    sort(w2.begin(), w2.end());
}

int getMinimumFuelCapacity(int X, int Y) {
    if(bambusz)return -1;
    int mx = 0;
    if(X != 0) mx = max(mx, w1[X]);
    if(Y != 0) mx = max(mx, w1[Y]);
    int i = 0;
    if(X == w2[i].second || Y == w2[i].second)i++;
    if(X == w2[i].second || Y == w2[i].second)i++;
    if(X == 0 || Y == 0){
        int j = i+1;
        if(X == w2[j].second || Y == w2[j].second)j++;
        if(X == w2[j].second || Y == w2[j].second)j++;
        return max(mx, max(w2[i].first, w2[j].second));
    }
    return max(mx, w2[i].first);
}

/*

4 3
0 1 1
0 2 2
0 3 3
4
1 2
1 3
0 1
3 0

*/

# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 101 ms 6760 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -