# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1069721 | UmairAhmadMirza | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 991 ms | 600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
bool are_connected(vector<int> A, vector<int> B);
int const MAXN=260;
bool con[MAXN][MAXN];
vector<int> path,longest;
bool vis[MAXN];
int nn;
void dfs(int node){
path.push_back(node);
if(path.size()>longest.size())
longest=path;
vis[node]=1;
for(int i=0;i<nn;i++)
if(vis[i]==0 && con[node][i])
dfs(i);
path.pop_back();
}
vector<int> longest_trip(int n, int D){
longest.clear();
nn=n;
vector<int> a,b;
for(int i=0;i<n;i++){
a.push_back(i);
for(int j=i+1;j<n;j++){
b.push_back(j);
con[i][j]=con[j][i]=are_connected(a,b);
b.pop_back();
}
a.pop_back();
}
if(D>1){
path.clear();
for (int i = 0; i < n; ++i)
path.push_back(i);
bool bl=0;
for(int i=0;i<n-1;i++)
if(con[path[i]][path[i+1]]==0){
if(i==n-2)
rotate(path.rbegin(), path.rbegin() + 1, path.rend());
else
swap(path[i+1],path[i+2]);
}
return path;
}
for (int i = 0; i < n; ++i)
{
path.clear();
for(int j=0;j<n;j++)
vis[j]=0;
dfs(i);
}
return longest;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |