| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 841329 | NicolaAbusaad2014 | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 21 ms | 516 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
vector<int>join(vector<int>&A,vector<int>&B)
{
vector<int>ret=A;
for(int i=0;i<B.size();i++){
ret.push_back(B[i]);
}
return ret;
}
bool are_connected(int a,int b)
{
return are_connected(vector<int>(1,a),vector<int>(1,b));
}
std::vector<int> longest_trip(int N, int D)
{
vector<vector<int> >path(N);
for(int i=0;i<N;i++){
path[i].push_back(i);
}
while(path.size()>2){
int sz=path.size();
vector<int>A=path[sz-1],B=path[sz-2],C=path[sz-3];
if(are_connected(A.back(),B[0])){
path.pop_back();
path.pop_back();
path.push_back(join(A,B));
continue;
}
if(are_connected(A.back(),C[0])){
path.pop_back();
path.pop_back();
path.pop_back();
path.push_back(join(A,C));
path.push_back(B);
continue;
}
path.pop_back();
path.pop_back();
path.pop_back();
path.push_back(A);
reverse(all(B));
path.push_back(join(B,C));
}
if(are_connected(path[0][0],path[1][0])){
reverse(all(path[0]));
return join(path[0],path[1]);
}
if(are_connected(path[0][0],path[1].back())){
return join(path[1],path[0]);
}
if(are_connected(path[0].back(),path[1][0])){
return join(path[0],path[1]);
}
if(are_connected(path[0].back(),path[1].back())){
reverse(all(path[1]));
return join(path[0],path[1]);
}
if(path[0].size()>=path[1].size()){
return path[0];
}
return path[1];
}
컴파일 시 표준 에러 (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... | ||||
