Submission #1226081

#TimeUsernameProblemLanguageResultExecution timeMemory
1226081paskalisapoFun Tour (APIO20_fun)C++20
0 / 100
0 ms324 KiB
#include "fun.h" #include <bits/stdc++.h> #include <vector> using namespace std; stack<int> s; vector<vector<pair<int,int>>> adj; vector<int> v; bool valid = false; int n; void dfs(int cur, int par, int mw) { for(auto &x : adj[cur]) { if(x.first == par || x.second > mw) { continue; } dfs(x.first, cur, x.second); s.push(x.first); } if(s.size() == n) { while(!s.empty()) { v.push_back(s.top()); s.pop(); } valid = true; return; } else { s.pop(); } } std::vector<int> createFunTour(int N, int Q) { int H = hoursRequired(0, N - 1); int A = attractionsBehind(0, N - 1); return std::vector<int>(N); n = N; adj.resize(N); for(int i = 0;i < N ; i++){ for(int j = i + 1; j < N ;j ++) { int temp = hoursRequired(i , j); if(attractionsBehind(i, j) == 0) { adj[i].push_back({j, temp}); adj[j].push_back({i , temp}); } } } for(int i = 0 ;i < N ;i++) { dfs(i , -1, INT_MAX); if(valid) { break; } } reverse(v.begin(), v.end()); for(auto &x : v) { cout << x << " "; } cout << endl; }
#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...