이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "longesttrip.h"
#include <bits/stdc++.h>
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repa(a,b) for(auto a:b)
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define pf push_front
#define fi first
#define se second
using namespace std;
vector<int> longest_trip(int N, int D){
if(D==1){
deque<vector<int>> ans;
rep(i,0,N){
ans.pb({i});
}
while(ans.size()>2){
if(are_connected({ans[0].back()},{ans[1].back()})){
reverse(ans[1].begin(),ans[1].end());
repa(e,ans[1]) ans[0].pb(e);
ans.erase(ans.begin()+1);
}else if(are_connected({ans[0].back()},{ans[2].back()})){
reverse(ans[2].begin(),ans[2].end());
repa(e,ans[2]) ans[0].pb(e);
ans.erase(ans.begin()+2);
}else{
reverse(ans[2].begin(),ans[2].end());
repa(e,ans[2]) ans[1].pb(e);
ans.erase(ans.begin()+2);
}
}
if(ans[0].size()>ans[1].size()) return ans[0];
else return ans[1];
}else{
deque<int> ans;
vector<int> aaa;
ans.pb(0);
int lf;
if(are_connected({1},{0})) ans.pb(1), lf=2;
else ans.pb(2), lf=1;
if(are_connected({1},{2})) ans.pb(lf);
else ans.pf(lf);
rep(i,3,N){
if(are_connected({i},{ans.back()})) ans.pb(i);
else ans.pf(i);
}
repa(e,ans) aaa.pb(e);
return aaa;
}
}
# | 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... |