Submission #436110

#TimeUsernameProblemLanguageResultExecution timeMemory
436110HediChehaidarFun Tour (APIO20_fun)C++17
0 / 100
1 ms204 KiB
/* ID: hedichehaidar TASK: photo LANG: C++11 */ #include<bits/stdc++.h> #include "fun.h" typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef double db; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM) #define ss second #define ff first #define all(x) (x).begin() , (x).end() #define pb push_back #define vi vector<int> #define vii vector<pair<int,int>> #define vl vector<ll> #define vll vector<pair<ll,ll>> #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define vdd vector<pdd> #define dte tuple<double , double , double> using namespace std; const int INF = 1000*1000*1000; // 1 e 9 const int MOD = INF + 7; const double EPS = 0.000000001; // 1 e -9 const ll inf = (ll)1e18; bool vis[505]; int dist[505][505]; int n; vi createFunTour(int N , int Q){ n = N; for(int i = 0 ; i < n ; i++){ for(int j = i + 1 ; j < n ; j++){ dist[i][j] = dist[j][i] = hoursRequired(i , j); } } int mx = 1; for(int i = 2 ; i < n ; i++){ if(dist[0][i] > dist[0][mx]) mx = i; } int cur = 0; for(int i = 0 ; i < n ; i++){ if(dist[mx][i] > dist[mx][cur]) cur = i; } vis[cur] = true; vi res; res.pb(cur); int nb = 1; while(nb < n){ int mx = cur; for(int i = 0 ; i < n ; i++){ if(dist[cur][i] > dist[cur][mx] && !vis[i]) { mx = i; } vis[mx] = true; res.pb(mx); cur = mx; nb++; break; } } return res; } /*int main() { //ifstream fin ("race.in"); //ofstream fout ("race.out"); ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); return 0; }*/ /* Think of : BS / DFS / BFS / SSSP / SCC / MSP / MAX FLOW / TOPSORT / LCA / MATRIX / DP(bitmask) / 2 POINTERS / SEG TREE / MATH / UN FIND / MO Read the statement CAREFULLY !! Make a GREADY APPROACH !!!! (start from highest / lowest) Make your own TESTS !! Be careful from CORNER CASES ! */
#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...