# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1126843 | BlancaHM | Saveit (IOI10_saveit) | C++17 | 72 ms | 5952 KiB |
#include "grader.h"
#include "encoder.h"
#include <queue>
#include <vector>
using namespace std;
vector<int> shortest_path_to_all_cities(int source, vector<vector<int>> & adjacency) {
// Calculate length of shortest path from source to all cities in graph.
int num_cities = (int) adjacency.size();
vector<int> distances(num_cities, num_cities + 1);
distances[source] = 0;
queue<int> bfs_queue;
bfs_queue.push(source);
while (!bfs_queue.empty()) {
int city = bfs_queue.front();
bfs_queue.pop();
for (int & neighbour: adjacency[city]) {
if (distances[neighbour] > distances[city] + 1) {
distances[neighbour] = distances[city] + 1;
bfs_queue.push(neighbour);
}
}
}
return distances;
}
vector<vector<int>> calculate_distances_to_hubs(
vector<vector<int>> & adjacency, int num_hubs
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |