| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 841577 | flashmt | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 781 ms | 848 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> longest_trip(int n, int d)
{
if (d == 3)
{
vector<int> ans(n);
iota(begin(ans), end(ans), 0);
return ans;
}
vector<vector<int>> a(n, vector<int>(n));
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
a[i][j] = a[j][i] = are_connected({i}, {j});
auto addToPath = [&](vector<int> &path, int x)
{
if (a[x][path[0]]) path.insert(begin(path), x);
else if (a[x][path.back()]) path.push_back(x);
else
{
for (int i = 0; i < size(path); i++)
if (a[x][path[i]])
{
rotate(begin(path), begin(path) + (i + 1), end(path));
path.push_back(x);
return;
}
}
};
vector<int> seen(n);
vector<int> ans;
for (int i = 0; i < n; i++)
if (!seen[i])
{
queue<int> q;
q.push(i);
seen[i] = 1;
vector<int> path = {i};
while (!empty(q))
{
int x = q.front();
q.pop();
for (int y = 0; y < n; y++)
if (!seen[y] && a[x][y])
{
seen[y] = 1;
q.push(y);
addToPath(path, y);
}
}
if (size(path) > size(ans))
ans = path;
}
return ans;
}
컴파일 시 표준 에러 (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... | ||||
