Submission #979498

# Submission time Handle Problem Language Result Execution time Memory
979498 2024-05-11T06:42:47 Z bubble_xd Swapping Cities (APIO20_swap) C++17
7 / 100
76 ms 11076 KB
#include "swap.h"

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

const int nax = 100005;
int N, M;
vector<pair<int, pair<int, int>>> edges; // (W, (U, V))
int to[nax];
void init(int _N, int _M, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
  N = _N; M = _M;
  for (int i = 0; i < M; i++) {
    edges.push_back(make_pair(W[i], make_pair(U[i], V[i])));
    to[V[i]] = W[i];
  }
  sort(edges.begin(), edges.end());
}

int getMinimumFuelCapacity(int X, int Y) {
  if (N <= 3) return -1;
  if (X > Y) swap(X, Y);
  if (X == 0) {
    int cnt = 0, mx = to[Y];
    for (int i = 0; i < M; i++) {
      if (edges[i].second.second != Y) {
        cnt++;
        mx = max(mx, edges[i].first);
        if (cnt >= 2) return mx;
      }
    }
  }
  else {
    for (int i = 0; i < M; i++) {
      if (edges[i].second.second != X && edges[i].second.second != Y) {
        return max({to[X], to[Y], edges[i].first});
      }
    }
  }
}

// #include "grader.cpp"

Compilation message

swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
   40 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 76 ms 7272 KB Output is correct
4 Correct 73 ms 7148 KB Output is correct
5 Correct 74 ms 7516 KB Output is correct
6 Correct 74 ms 10800 KB Output is correct
7 Correct 75 ms 11076 KB Output is correct
8 Correct 75 ms 10808 KB Output is correct
9 Correct 73 ms 11076 KB Output is correct
10 Correct 75 ms 11036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -