제출 #296150

#제출 시각아이디문제언어결과실행 시간메모리
296150Alexa2001즐거운 행로 (APIO20_fun)C++17
0 / 100
1 ms384 KiB
#include "fun.h" #include <bits/stdc++.h> using namespace std; const int Nmax = 1e5 + 5; int n; vector<int> ans; bool used[Nmax]; int dist[Nmax]; void add(int node) { ans.push_back(node); used[node] = 1; } void solve(int node) { int i, j; for(i=1; i<n; ++i) dist[i] = hoursRequired(0, i); int root = 0; while(1) { vector<int> sons; vector<vector<int>> d; for(j=1; j<=n; ++j) if(!used[j] && dist[j] == dist[root] + 1) sons.push_back(j); if(sons.empty()) { add(root); return; } d.resize(sons.size()); for(j=0; j<n; ++j) if(!used[j]) { int where = 0; for(i=1; !where && i<sons.size(); ++i) if(dist[j] == dist[sons[i]] + hoursRequired(sons[i], j)) where = i; d[where].push_back(j); } for(i=0; i<sons.size(); ++i) sort(d[i].begin(), d[i].end(), [&] (int x, int y) { return dist[x] < dist[y];} ); if(sons.size() == 1) { add(d[0].back()); add(root); root = sons[0]; continue; } int last = -1; while(1) { int best = -1, nd = -1; for(i=0; i<sons.size(); ++i) if(i != last && d[i].size() && dist[d[i].back()] > best) best = dist[d[i].back()], nd = i; if(nd == -1) break; add(d[nd].back()); d[nd].pop_back(); last = nd; } add(root); root = -1; for(i=0; i<sons.size(); ++i) if(d[i].size()) root = sons[i]; if(root == -1) return; } } vector<int> createFunTour(int N, int Q) { n = N; solve(0); return ans; }

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

fun.cpp: In function 'void solve(int)':
fun.cpp:48:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |                 for(i=1; !where && i<sons.size(); ++i)
      |                                    ~^~~~~~~~~~~~
fun.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(i=0; i<sons.size(); ++i)
      |                  ~^~~~~~~~~~~~
fun.cpp:72:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |             for(i=0; i<sons.size(); ++i)
      |                      ~^~~~~~~~~~~~
fun.cpp:86:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |         for(i=0; i<sons.size(); ++i)
      |                  ~^~~~~~~~~~~~
#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...