제출 #440738

#제출 시각아이디문제언어결과실행 시간메모리
440738Maurimuri80열쇠 (IOI21_keys)C++17
9 / 100
3075 ms9632 KiB
#include <vector> #include <iostream> #include <queue> using namespace std; //array r son las llaves en la habitacion // u y v son el destino y partida de cada conector // c on las llaves necesarias para recorrer el corredor //vector p cantidad de habitaciones alcanzables vector<int> p; vector<int> Vis; queue<int> bfsq; vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { vector<int> ans(r.size(), 1); p.assign(r.size(),-1); int visitados,minimo = r.size() +1,padre,hijo; for (int i = 0; i < r.size(); i++) { if (r[i] == 0) { visitados = 0; Vis.assign(r.size(),-1); Vis[i] = 1; bfsq.push(i); while (bfsq.size() > 0) { padre = bfsq.front(); bfsq.pop(); for (int h = 0; h < u.size(); h++) { if (u[h] == padre) { if (Vis[v[h]] == -1) { Vis[v[h]] = 1; bfsq.push(v[h]); } } if (v[h] == padre) { if (Vis[u[h]] == -1) { Vis[u[h]] = 1; bfsq.push(u[h]); } } } } for (int j = 0; j < Vis.size(); j++) { if (Vis[j] != -1) { visitados++; } } p[i] = visitados; minimo = min(minimo,visitados); }else{ minimo = 1; p[i] = 1; } } for (int i = 0; i < r.size(); i++) { if (p[i] != minimo) { ans[i] = 0; } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for (int i = 0; i < r.size(); i++)
      |                  ~~^~~~~~~~~~
keys.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int h = 0; h < u.size(); h++)
      |                     ~~^~~~~~~~~~
keys.cpp:57:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |    for (int j = 0; j < Vis.size(); j++)
      |                    ~~^~~~~~~~~~~~
keys.cpp:71:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |  for (int i = 0; i < r.size(); i++)
      |                  ~~^~~~~~~~~~
keys.cpp:19:43: warning: unused variable 'hijo' [-Wunused-variable]
   19 |  int visitados,minimo = r.size() +1,padre,hijo;
      |                                           ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...