답안 #1064772

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1064772 2024-08-18T17:37:09 Z Osplei 기지국 (IOI20_stations) C++17
5 / 100
627 ms 1016 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];
  queue <int> q;
  int pos = 0;

  for (int i = 0; i < 1005; i++) visto[i] = false;

  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];

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

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

  for (int i = 0; i < n; i++){
    if (grafo[i].size() == 1){
      vector <int> labels = bfs(n, i, grafo);
      //for (auto j : labels) cout << j << " ";
      return labels;
    }
  }

  return u;
	
}

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]);
}

/*

int main(){
  label(5, 10, {0, 3, 4, 2}, {1, 4, 0, 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++) {
      |                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 363 ms 684 KB Output is correct
2 Correct 320 ms 684 KB Output is correct
3 Correct 605 ms 684 KB Output is correct
4 Correct 468 ms 684 KB Output is correct
5 Correct 404 ms 684 KB Output is correct
6 Correct 339 ms 688 KB Output is correct
7 Correct 298 ms 684 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 290 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 391 ms 684 KB Output is correct
2 Correct 300 ms 684 KB Output is correct
3 Correct 600 ms 684 KB Output is correct
4 Correct 467 ms 688 KB Output is correct
5 Correct 395 ms 684 KB Output is correct
6 Correct 287 ms 684 KB Output is correct
7 Correct 297 ms 684 KB Output is correct
8 Correct 2 ms 780 KB Output is correct
9 Correct 2 ms 776 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Incorrect 432 ms 684 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 616 ms 684 KB Output is correct
2 Correct 492 ms 684 KB Output is correct
3 Correct 377 ms 684 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Incorrect 404 ms 684 KB Wrong query response.
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 344 ms 684 KB Output is correct
2 Correct 315 ms 684 KB Output is correct
3 Correct 627 ms 688 KB Output is correct
4 Correct 503 ms 684 KB Output is correct
5 Correct 397 ms 684 KB Output is correct
6 Correct 272 ms 684 KB Output is correct
7 Correct 307 ms 684 KB Output is correct
8 Correct 1 ms 1016 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 776 KB Output is correct
11 Incorrect 289 ms 684 KB Wrong query response.
12 Halted 0 ms 0 KB -