# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1030212 | Agreb | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 867 ms | 692 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
vector <int> longest_trip(int N, int D){
vector <vector<int>> gr(N, vector<int>(N, 0));
vector <int> path;
for (int i = 0; i < N; i++){
for (int j = 0; j < i; j++){
vector <int> a{i}, b{j};
gr[i][j] = gr[j][i] = are_connected(a, b);
if (gr[i][j]){
path = {i, j};
}
}
}
assert(!path.empty());
vector <int> on_path(N);
for (int u : path) on_path[u] = 1;
while (path.size() < N){
int P = path.size();
int st = path[0], fin = path[P-1];
int done = 0;
for (int v = 0; v < N; v++){
if (!on_path[v]){
if (gr[st][v]){
reverse(path.begin(), path.end());
path.push_back(v);
on_path[v] = 1;
done = 1;
break;
}
if (gr[fin][v]){
path.push_back(v);
on_path[v] = 1;
done = 1;
break;
}
}
}
if (done) continue;
assert(gr[st][fin] == 1);
for (int v = 0; v < N; v++){
if (!on_path[v]){
for (int i = 0; i < P; i++){
if (gr[path[i]][v]){
vector <int> npath;
for (int j = 0; j < P; j++)
npath.push_back(path[(j+i+1)%P]);
npath.push_back(v);
path = npath;
on_path[v] = 1;
done = 1;
break;
}
}
if (done) break;
}
}
if (done) continue;
if (P >= N - P) return path;
else{
vector <int> npath;
for (int v = 0; v < N; v++){
if (!on_path[v]) npath.push_back(v);
}
return npath;
}
}
return path;
}
컴파일 시 표준 에러 (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... |