Submission #979506

# Submission time Handle Problem Language Result Execution time Memory
979506 2024-05-11T06:53:50 Z ducksaysquack Swapping Cities (APIO20_swap) C++17
7 / 100
85 ms 7508 KB
//#include "swap.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
int n, m;
vector<pair<int,pair<int,int>>> e;
vector<int> to(1e5+5);
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
	n = N, m = M;
	for(int i=0;i<m;i++) {e.pb({W[i],{U[i],V[i]}}); to[V[i]] = W[i];}
	sort(begin(e),end(e));
}
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(e[i].s.s != y) {
			cnt++, mx = max(mx, e[i].f);
			if(cnt >= 2) return mx;
		}
	}
	else for(int i=0;i<m;i++) if(e[i].s.s != x && e[i].s.s != y) return max({to[x], to[y], e[i].f});
}

Compilation message

swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
   26 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Incorrect 1 ms 604 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 70 ms 7092 KB Output is correct
4 Correct 85 ms 7220 KB Output is correct
5 Correct 79 ms 7508 KB Output is correct
6 Correct 70 ms 6960 KB Output is correct
7 Correct 71 ms 7336 KB Output is correct
8 Correct 74 ms 7028 KB Output is correct
9 Correct 71 ms 7240 KB Output is correct
10 Correct 71 ms 7296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Incorrect 1 ms 604 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Incorrect 1 ms 604 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Incorrect 1 ms 604 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Incorrect 1 ms 604 KB Output isn't correct
5 Halted 0 ms 0 KB -