Submission #762755

#TimeUsernameProblemLanguageResultExecution timeMemory
762755MohamedFaresNebiliFun Tour (APIO20_fun)C++14
26 / 100
24 ms724 KiB
#include <bits/stdc++.h> using namespace std; int hoursRequired(int X, int Y); vector<int> adj[505]; int cur, node; vector<bool> vis; void dfs(int v, int p, int d) { if(d >= cur) node = v, cur = d; for(auto u : adj[v]) { if(u == p || vis[u]) continue; dfs(u, v, d + 1); } } vector<int> createFunTour(int N, int Q) { vis.assign(N, 0); for(int l = 0; l < N; l++) { for(int i = l + 1; i < N; i++) { int dist = hoursRequired(l, i); if(dist != 1) continue; adj[l].push_back(i); adj[i].push_back(l); } } dfs(0, 0, 0); int st = node; cur = -1; vector<int> res; res.push_back(st); vis[st] = 1; while(res.size() < N) { dfs(st, st, 0); cur = -1; vis[node] = 1; res.push_back(node); swap(st, node); } return res; }

Compilation message (stderr)

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:30:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |    while(res.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...