제출 #436162

#제출 시각아이디문제언어결과실행 시간메모리
436162aymane7즐거운 행로 (APIO20_fun)C++17
26 / 100
384 ms26852 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){ vector<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.PB({a,{i,j}}); pq.PB({a,{j,i}}); } sort(all(pq)); reverse(all(pq)); vector<bool> vis(n,0); int cur=pq[0].S.F; vector<int> ans; ans.PB(cur); vis[cur]=1; while(sz(ans)<n){ int mxd=-1,mxi=-1; for(int i=0;i<sz(pq);i++) if(pq[i].S.F==cur && pq[i].F>mxd && !vis[pq[i].S.S]){ mxd=pq[i].F,mxi=pq[i].S.S; } vis[mxi]=1; cur=mxi; ans.PB(cur); } /* 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...