# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
992851 | Muhammet | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 960 ms | 3784 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "longesttrip.h"
#define N 3005
using namespace std;
vector <int> v[N], v1;
int c[N], k, y;
bool vis[N][N], vi[N];
void dfs(int x){
vi[x] = 1;
if(k < c[x]) y = x;
k = max(c[x], k);
for(auto i : v[x]){
if(vi[i] == 0){
c[i] = c[x] + 1;
dfs(i);
}
}
}
void df(int x){
v1.push_back(x);
if(c[x] == 1) return;
for(auto i : v[x]){
if(c[i] == c[x] - 1){
df(i);
break;
}
}
}
vector<int> longest_trip(int n, int d) {
vector <int> a(1), b(1);
for(int i = 0; i < n; i++) v[i].clear();
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
vis[i][j] = 0;
}
}
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++){
a[0] = i;
b[0] = j;
if(are_connected(a, b) and vis[i][j] == 0) {
vis[i][j] = 1;
vis[j][i] = 1;
v[i].push_back(j);
v[j].push_back(i);
}
}
}
v1.clear();
int mx = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++) vi[j] = c[j] = 0;
k = y = 0;
c[i] = 1;
dfs(i);
if(k > mx){
mx = k;
v1.clear();
df(y);
}
}
reverse(v1.begin(), v1.end());
return v1;
}
컴파일 시 표준 에러 (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... |