제출 #735365

#제출 시각아이디문제언어결과실행 시간메모리
735365keisuke6즐거운 행로 (APIO20_fun)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> 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); 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]){ best = dist[i]; now = i; } } return A; }

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

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:7:13: error: 'hoursRequired' was not declared in this scope
    7 |     int a = hoursRequired(i, j);
      |             ^~~~~~~~~~~~~
fun.cpp:30:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |   while(A.size() != N){
      |         ~~~~~~~~~^~~~