제출 #812391

#제출 시각아이디문제언어결과실행 시간메모리
812391Hanksburger즐거운 행로 (APIO20_fun)C++17
26 / 100
40 ms16880 KiB
#include "fun.h" #include <bits/stdc++.h> using namespace std; int dist[100005], bad[100005], n; vector<int> adj[100005], ans; queue<pair<int, int> > q; void recur(int u) { vector<int> vecL, vecR; if (u*2+1<n) vecL.push_back(u*2+1); for (int i=0; i<vecL.size(); i++) { if (vecL[i]*2+1<n) vecL.push_back(vecL[i]*2+1); if (vecL[i]*2+2<n) vecL.push_back(vecL[i]*2+2); } if (u*2+2<n) vecR.push_back(u*2+2); for (int i=0; i<vecR.size(); i++) { if (vecR[i]*2+1<n) vecR.push_back(vecR[i]*2+1); if (vecR[i]*2+2<n) vecR.push_back(vecR[i]*2+2); } reverse(vecL.begin(), vecL.end()); reverse(vecR.begin(), vecR.end()); for (int i=0; i<vecR.size(); i++) { ans.push_back(vecL[i]); ans.push_back(vecR[i]); } if (vecL.size()>vecR.size()) { if (!vecR.empty()) n=vecL[vecR.size()-1]; recur(u*2+1); } ans.push_back(u); } vector<int> createFunTour(int nn, int qq) { n=nn; if (n<=500) { for (int i=0; i<n; i++) { for (int j=i+1; j<n; j++) { if (hoursRequired(i, j)==1) { adj[i].push_back(j); adj[j].push_back(i); } } } int cur=0; for (int i=0; i<n; i++) { for (int j=0; j<n; j++) dist[j]=1e9; dist[cur]=0; q.push({cur, -1}); while (!q.empty()) { int u=q.front().first, p=q.front().second; q.pop(); for (int v:adj[u]) { if (v==p || bad[v]) continue; dist[v]=dist[u]+1; q.push({v, u}); } } int ind, mx=-1; for (int j=0; j<n; j++) { if (!bad[j] && mx<dist[j]) { mx=dist[j]; ind=j; } } ans.push_back(ind); bad[ind]=1; cur=ind; } return ans; } recur(0); return ans; }

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

fun.cpp: In function 'void recur(int)':
fun.cpp:12:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i=0; i<vecL.size(); i++)
      |                   ~^~~~~~~~~~~~
fun.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<vecR.size(); i++)
      |                   ~^~~~~~~~~~~~
fun.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i=0; i<vecR.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...