Submission #436151

#TimeUsernameProblemLanguageResultExecution timeMemory
436151aymane7Fun Tour (APIO20_fun)C++17
0 / 100
1 ms204 KiB
#include<bits/stdc++.h> #include "fun.h" #pragma GCC optimize("O2") #define deb(x) cout << #x << " = " << x <<endl #define F first #define S second #define PB push_back #define MP make_pair #define all(c) c.begin(), c.end() #define endl "\n" #define sz(u) (int)(u.size()) #define L(x)(2*x) #define R(x)(2*x+1) #define M(x,y)((x+y)/2) typedef long long ll; typedef unsigned long long ull; using namespace std; /* int hoursRequired(int x,int y){ cout<<x<<" "<<y<<endl; int ans; cin>>ans; return ans; assert(0); } */ vector<int> createFunTour(int n,int q){ priority_queue<pair<int,pair<int,int>>> pq; for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(i!=j){ assert(i<n && i>=0 && j>=0 && j<n); int a=hoursRequired(i,j); pq.push({a,{i,j}}); pq.push({a,{j,i}}); } vector<int> ans; int cur=pq.top().S.F; ans.PB(cur); vector<bool> vis(n,0); vis[cur]=1; while(!pq.empty()){ auto u=pq.top(); pq.pop(); if(u.S.F!=cur || vis[u.S.S]) continue; cur=u.S.S; ans.PB(cur); vis[cur]=1; } /* for(auto x:ans) cout<<x<<" "; */ return ans; } /* int main(){ createFunTour(2,0); } */
#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...