Submission #466159

#TimeUsernameProblemLanguageResultExecution timeMemory
466159flappybirdFun Tour (APIO20_fun)C++14
0 / 100
1 ms332 KiB
#include "fun.h" #include <bits/stdc++.h> using namespace std; typedef int ll; vector<int> createFunTour(int N, int Q) { if (N == 2) { vector<ll> v; v.push_back(0); v.push_back(1); return v; } vector<ll> res; ll i; for (i = 0; i < N; i++) res.push_back(attractionsBehind(0, i)); ll c = 0; ll mx = 0; for (i = 0; i < N; i++) { if ((2 * (N - res[i]) <= N) && (2 * (res[i] - 1) <= N)) { if (mx < res[i]) mx = res[i], c = i; } } vector<pair<ll, ll>> dis; vector<vector<pair<ll, ll>>> subtree; subtree.resize(3); ll num; for (i = 0; i < N; i++) { if (i == c) continue; dis.push_back({ hoursRequired(i, c), i }); } sort(dis.begin(), dis.end()); num = 1; subtree[0].push_back(dis[0]); for (i = 1; i < dis.size(); i++) { ll j; for (j = 0; j < num; j++) { if (hoursRequired(dis[i].second, subtree[j][0].second) != dis[i].first + subtree[j][0].first) break; } if (j == num) num++; subtree[j].push_back(dis[i]); } vector<ll> ans; if (num == 2) { ll r = N; ll a; if (subtree[0].size() < subtree[1].size()) a = 1; else a = 0; while (r != 1) { ans.push_back(subtree[a][subtree[a].size() - 1].second); subtree[a].pop_back(); a = !a; r--; } ans.push_back(c); } else { ll r = N; ll a; if (subtree[0].size() > subtree[1].size()) swap(subtree[0], subtree[1]); if (subtree[1].size() > subtree[2].size()) swap(subtree[1], subtree[2]); if (subtree[0].size() > subtree[1].size()) swap(subtree[0], subtree[1]); a = 2; while (r != 1) { ans.push_back(subtree[a][subtree[a].size() - 1].second); subtree[a].pop_back(); ll b, c; b = a + 1; c = a + 2; b %= 3; c %= 3; if (subtree[b].size() < subtree[c].size()) a = c; else a = b; r--; } ans.push_back(c); } return ans; }

Compilation message (stderr)

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:35:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for (i = 1; i < dis.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...