Submission #1064734

# Submission time Handle Problem Language Result Execution time Memory
1064734 2024-08-18T17:17:38 Z Osplei Stations (IOI20_stations) C++17
0 / 100
603 ms 688 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

#define pb push_back

vector <int> bfs (int n, int nodo, vector <int> grafo[1005]){
  vector <int> aux(n);
  bool visto[1005] = {false};
  queue <int> q;
  int pos = 0;

  q.push(nodo);

  while (!q.empty()){
    int act = q.front();
    q.pop();

    if (visto[act] == true) continue;

    visto[act] = true;

    for (auto i : grafo[act]) q.push(i);

    aux[act] = pos;
    pos++;
  }

  return aux; 
}

vector <int> label(int n, int k, vector <int> u, vector <int> v) {
	
  vector <int> grafo[1005];

  map <int, int> entra;

  for (int i = 0; i < u.size(); i++) {
    int a = u[i], b = v[i];

    if (b < a) swap(a, b);

    entra[b]++;

    grafo[a].pb(b);
    grafo[b].pb(a);
  }

  for (auto i : entra) {
    vector <int> labels = bfs(n, i.first, grafo);
    return labels;
  }
	
}

int find_next_station(int s, int t, vector <int> c) {

  if (c.size() == 1) return c[0];
	
  if (t > s) return max(c[0], c[1]);
  else return min(c[0], c[1]);
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:39:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for (int i = 0; i < u.size(); i++) {
      |                   ~~^~~~~~~~~~
stations.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 370 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 321 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 351 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 603 ms 684 KB Output is correct
2 Incorrect 416 ms 684 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 401 ms 688 KB Wrong query response.
2 Halted 0 ms 0 KB -