#include "longesttrip.h"
#include<bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define ask are_connected
vector<int> adj[260];
bitset<260> vis;
vector<int> ans;
void dfs(int u){
vis[u]=1;
ans.eb(u);
for(auto &v:adj[u]){
if(!vis[v]) dfs(v);
}
}
std::vector<int> longest_trip(int N, int D)
{
if(D==1){
ans.resize(N);
iota(ans.begin(),ans.end(),0);
return ans;
}
for(int i=0;i<N;++i) adj[i].clear();
if(D==2){
for(int i=0;i+1<N;++i){
if(ask({i},{i+1})) adj[i].eb(i+1), adj[i+1].eb(i);
else for(int j=0;j<N;++j){
if(i<=j&&j<=i+1) continue;
adj[j].eb(i), adj[i].eb(j);
adj[j].eb(i+1), adj[i+1].eb(j);
}
}
vis.reset();
dfs(0);
return ans;
}
return{};
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Incorrect |
1 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |