Submission #1069440

#TimeUsernameProblemLanguageResultExecution timeMemory
1069440pawnedFun Tour (APIO20_fun)C++17
26 / 100
21 ms2496 KiB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops") #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; #include "fun.h" const int MAX = 505; int N; vi adj[MAX]; int dist[MAX][MAX]; vi createFunTour(int N_g, int Q) { N = N_g; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { dist[i][j] = hoursRequired(i, j); if (dist[i][j] == 1) adj[i].pb(j); } } // start with a diameter point int start = -1; int maxd = -1; for (int i = 0; i < N; i++) { if (dist[0][i] > maxd) { start = i; maxd = dist[0][i]; } } vi ans; vector<bool> vis(N, false); vis[start] = true; ans.pb(start); int curr = start; for (int i = 0; i < N - 1; i++) { int nextp = -1; maxd = -1; for (int j = 0; j < N; j++) { if (vis[j]) continue; if (dist[curr][j] > maxd) { nextp = j; maxd = dist[curr][j]; } } curr = nextp; ans.pb(curr); vis[curr] = true; } /* cout<<"ANSWER: "; for (int x : ans) cout<<x<<" "; cout<<endl;*/ return ans; }
#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...