# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1014190 | JakobZorz | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 908 ms | 1292 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"longesttrip.h"
#include<iostream>
using namespace std;
int n;
vector<int>nodes[500];
vector<int>longest_trip(int N,int D){
n=N;
for(int i=0;i<n;i++)
nodes[i].clear();
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(are_connected({i},{j})){
nodes[i].push_back(j);
nodes[j].push_back(i);
//cout<<"CONN "<<i<<" "<<j<<"\n";
}
}
}
vector<int>res={0};
vector<bool>vis(n);
vis[0]=true;
while(true){
int node=res.back();
//cout<<"VIS "<<node<<"\n";
for(int ne:nodes[node])
if(!vis[ne]){
res.push_back(ne);
break;
}
vis[res.back()]=true;
if(node==res.back())
break;
}
// all unvisited are now a strongly connected component
for(int i=0;i<(int)res.size();i++){
for(int ne:nodes[res[i]]){
if(!vis[ne]){
vector<int>res2;
for(int j=0;j<n;j++)
if(!vis[j])
res2.push_back(j);
for(int j=i;j<(int)res.size();j++)
res2.push_back(res[j]);
for(int j=0;j<i;j++)
res2.push_back(res[j]);
return res2;
}
}
}
if(2*res.size()<n){
vector<int>res2;
for(int j=0;j<n;j++)
if(!vis[j])
res2.push_back(j);
return res2;
}
return res;
}
컴파일 시 표준 에러 (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... |