Submission #1041824

# Submission time Handle Problem Language Result Execution time Memory
1041824 2024-08-02T08:32:36 Z Halym2007 Swapping Cities (APIO20_swap) C++17
7 / 100
208 ms 20100 KB
#include<bits/stdc++.h>
//#include "swap.h"
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define pii pair <int, int>
vector <int> V, U, W;
int subtask2 = 0, n, m;

set <pii> s;
map <int, int> mp;

void init(int N, int M, vector<int> U1, vector<int> V1, vector<int> W1) {
	n = N;m = M;V = V1;U = U1, W = W1;
	for (int i = 0; i < m; ++i) {
		if (U[i]) {
			subtask2 = 1;
//			break;
		}
		s.insert ({W[i], V[i]});
		mp[V[i]] = W[i];
	}
}

int getMinimumFuelCapacity(int X, int Y) {
	if (!subtask2) {
		if (m <= 2) return -1;
		int idx = -1;
		for (pii i : s) {
			if (i.ss != X and i.ss != Y and min(X, Y) != 0) {
				return max ({i.ff, mp[X], mp[Y]});
			} 
			else if (i.ss != X and i.ss != Y) {
				if (~idx) {
					return max ({i.ff, idx, mp[X], mp[Y]});
				}
				else idx = i.ff;
			}
		}
	}
}



//#include <cassert>
//#include <cstdio>
//
//#include <string>
//#include <vector>
//
//int main() {
//	freopen ("input.txt", "r", stdin);
//  int N, M;
//  assert(2 == scanf("%d %d", &N, &M));
//  
//  std::vector<int> U(M), V(M), W(M);
//  for (int i = 0; i < M; ++i) {
//    assert(3 == scanf("%d %d %d", &U[i], &V[i], &W[i]));
//  }
//
//  int Q;
//  assert(1 == scanf("%d", &Q));
//
//  std::vector<int> X(Q), Y(Q);
//  for (int i = 0; i < Q; ++i) {
//    assert(2 == scanf("%d %d", &X[i], &Y[i]));
//  }
//
//  init(N, M, U, V, W);
//  
//  std::vector<int> minimum_fuel_capacities(Q);
//  for (int i = 0; i < Q; ++i) {
//    minimum_fuel_capacities[i] = getMinimumFuelCapacity(X[i], Y[i]);
//  }
//
//  for (int i = 0; i < Q; ++i) {
//    printf("%d\n", minimum_fuel_capacities[i]);
//  }
//  
//  return 0;
//}

Compilation message

swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 187 ms 15624 KB Output is correct
4 Correct 197 ms 18364 KB Output is correct
5 Correct 182 ms 18156 KB Output is correct
6 Correct 208 ms 19896 KB Output is correct
7 Correct 192 ms 20100 KB Output is correct
8 Correct 191 ms 19368 KB Output is correct
9 Correct 202 ms 19664 KB Output is correct
10 Correct 175 ms 19212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -