| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1194509 | hackstar | 즐거운 행로 (APIO20_fun) | C++20 | 0 ms | 0 KiB | 
#include "fun.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>createFunTour(int n,int q){
	vector<vector<int>>dist(n,vector<int>(n));
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int cur=hoursRequired(i,j);
			dist[i][j]=cur;
		}
	}
	vector<int>o(n);
	iota(o.begin(),o.end(),0);
	auto check=[&]()->bool{	
		bool ok=1;
		int lst=dist[o[0]][o[1]];
		for(int i=2;i<n;i++){
			if(dist[o[i]][o[i-1]]>lst){
				return 0;
			}
			lst=dist[o[i]][o[i-1]];
		}
		return 1;
	};
	do{
		if(check()){
			break;
		}
	}while(next_permutation(all(o)));
	return o;
}
