제출 #735368

#제출 시각아이디문제언어결과실행 시간메모리
735368keisuke6즐거운 행로 (APIO20_fun)C++14
26 / 100
90 ms16720 KiB
#include "fun.h" #include <iostream> #include <queue> #include <vector> #include <set> using namespace std; std::vector<int> createFunTour(int N, int Q) { vector<vector<int>> G(N); for(int i=0;i<N;i++)for(int j=0;j<N;j++){ int a_ = hoursRequired(i, j); if(a_ == 1) G[i].push_back(j); } queue<int> q; q.push(0); vector<int> dist(N,1e9); dist[0] = 0; while(!q.empty()){ int pos = q.front(); q.pop(); for(int x:G[pos]){ if(dist[x] != 1e9) continue; q.push(x); dist[x] = dist[pos] + 1; } } int now = 0, best = 0; for(int i=0;i<N;i++)if(best < dist[i]){ best = dist[i]; now = i; } vector<int> A = {}; set<int> s; while(A.size() != N){ for(int i=0;i<N;i++) dist[i] = 1e9; A.push_back(now); s.insert(now); q.push(now); dist[now] = 0; while(!q.empty()){ int pos = q.front(); q.pop(); for(int x:G[pos]){ if(dist[x] != 1e9) continue; q.push(x); dist[x] = dist[pos] + 1; } } best = 0; for(int i=0;i<N;i++)if(best < dist[i] && !s.count(i)){ best = dist[i]; now = i; } } return A; }

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

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:34:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |   while(A.size() != N){
      |         ~~~~~~~~~^~~~
#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...