#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
const int nax = 2e5+5;
const int MOD = 1e9+7;
vector<int> adj[256];
std::vector<int> longest_trip(int N, int D)
{
for (int i = 0; i < N; ++i)
{
adj[i].clear();
}
if(N==3){
if(are_connected({0},{1})&&are_connected({1},{2})) return {0,1,2};
else return {0,2,1};
}
set<int> st;
for (int i = 0; i < N; ++i)
{
st.insert(i);
for (int j = i+1; j < N; ++j)
{
if(!are_connected({i},{j})){
adj[i].pb(j);
adj[j].pb(i);
}
}
}
int cur=0;
st.erase(0);
vector<int> ans;
ans.pb(0);
while(!st.empty()){
if(adj[cur].size()==1){
for(auto u:st) {
if(u==adj[cur][0]) continue;
cur=u;
ans.pb(u);
st.erase(u);
break;
}
}else{
cur=*st.begin();
ans.pb(*st.begin());
st.erase(*st.begin());
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
344 KB |
Output is correct |
2 |
Correct |
23 ms |
344 KB |
Output is correct |
3 |
Correct |
159 ms |
344 KB |
Output is correct |
4 |
Correct |
393 ms |
340 KB |
Output is correct |
5 |
Correct |
818 ms |
676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
24 ms |
344 KB |
Output is correct |
3 |
Correct |
145 ms |
444 KB |
Output is correct |
4 |
Correct |
388 ms |
672 KB |
Output is correct |
5 |
Correct |
857 ms |
436 KB |
Output is correct |
6 |
Incorrect |
0 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
15 ms |
344 KB |
Output is correct |
3 |
Correct |
156 ms |
344 KB |
Output is correct |
4 |
Correct |
427 ms |
344 KB |
Output is correct |
5 |
Correct |
859 ms |
932 KB |
Output is correct |
6 |
Incorrect |
1 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
23 ms |
344 KB |
Output is correct |
3 |
Partially correct |
150 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
429 ms |
424 KB |
Output is partially correct |
5 |
Partially correct |
808 ms |
600 KB |
Output is partially correct |
6 |
Incorrect |
1 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |