Submission #980832

#TimeUsernameProblemLanguageResultExecution timeMemory
980832c2zi6Fun Tour (APIO20_fun)C++14
26 / 100
76 ms16840 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "fun.h" int n; VVI gp; VI del; VI dist; void dfs(int u, int p = -1) { for (int v : gp[u]) if (v != p && !del[v]) { dist[v] = dist[u]+1; dfs(v, u); } } int heru(int u) { dist = VI(n, -1); dist[u] = 0; dfs(u); int ans = u; rep(v, n) if (dist[v] > dist[ans]) ans = v; return ans; } VI createFunTour(int N, int Q) { n = N; gp = VVI(n); replr(u, 0, n-1) replr(v, u+1, n-1) { if (hoursRequired(u, v) == 1) { gp[u].pb(v); gp[v].pb(u); } } del = VI(n); int cur = heru(0); VI ans; while (ans.size() < n) { ans.pb(cur); del[cur] = true; cur = heru(cur); } /* int H = hoursRequired(0, N - 1); */ /* int A = attractionsBehind(0, N - 1); */ return ans; }

Compilation message (stderr)

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