Submission #394160

#TimeUsernameProblemLanguageResultExecution timeMemory
394160IloveNFun Tour (APIO20_fun)C++14
26 / 100
13 ms2636 KiB
#include<bits/stdc++.h> #include "fun.h" using namespace std; #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define fi first #define se second #define mp make_pair #define pb push_back #define eb emplace_back #define all(vr) vr.begin(),vr.end() #define vi vector<int> #define vll vector<ll> const int N = 5e2 + 10; int d[N][N], vis[N]; vi createFunTour(int n, int Q) { //int H = hoursRequired(0, N - 1); //int A = attractionsBehind(0, N - 1); for (int i = 0; i < n; ++i) for (int j = i + 1; j < n; ++j) d[i][j] = d[j][i] = hoursRequired(i, j); int cur = 0; for (int i = 1; i < n; ++i) if (d[0][i] > d[0][cur]) cur = i; for (int i = 0; i < n; ++i) vis[i] = 0; vi ans; ans.eb(cur); vis[cur] = 1; for (int i = 1; i < n; ++i) { int nxt, mx = -1; for (int j = 0; j < n; ++j) if (!vis[j] && d[cur][j] > mx) nxt = j, mx = d[cur][j]; cur = nxt; ans.eb(cur); vis[cur] = 1; } return ans; } /*int main() { //freopen("ss.inp", "r", stdin); ios::sync_with_stdio(false); cin.tie(0); return 0; }*/

Compilation message (stderr)

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:34:13: warning: 'nxt' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |         int nxt, mx = -1;
      |             ^~~
#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...