#include "longesttrip.h"
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define P push
#define I insert
#define F first
#define S second
typedef long long ll;
vector<int> v[256];
int n,ans;
vector<int> t,curv;
bool visited[256];
void dfs(int x,int cur){
if(ans==n)return;
curv.PB(x);
visited[x]=true;
if(ans<cur){
t=curv;
ans=cur;
}
for(int i=0;i<v[x].size();i++){
int y=v[x][i];
if(visited[y])continue;
dfs(y,cur+1);
}
visited[x]=false;
curv.pop_back();
}
vector<int> longest_trip(int N, int D){
n=N;
if(D==3){
vector<int> tt;for(int i=0;i<n;i++)tt.PB(i);
return tt;
}
memset(visited,false,sizeof(visited));
for(int i=0;i<n;i++)v[i].clear();
ans=0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(are_connected({i},{j})){v[i].PB(j);v[j].PB(i);}
}
}
for(int i=0;i<n;i++){
dfs(i,1);
}
return t;
}
Compilation message
longesttrip.cpp: In function 'void dfs(int, int)':
longesttrip.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i=0;i<v[x].size();i++){
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
162 ms |
1616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 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 |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
20 ms |
344 KB |
Output is correct |
3 |
Correct |
123 ms |
860 KB |
Output is correct |
4 |
Correct |
312 ms |
1124 KB |
Output is correct |
5 |
Correct |
702 ms |
1540 KB |
Output is correct |
6 |
Correct |
6 ms |
344 KB |
Output is correct |
7 |
Correct |
23 ms |
344 KB |
Output is correct |
8 |
Correct |
128 ms |
600 KB |
Output is correct |
9 |
Correct |
260 ms |
1112 KB |
Output is correct |
10 |
Correct |
695 ms |
1396 KB |
Output is correct |
11 |
Correct |
667 ms |
1560 KB |
Output is correct |
12 |
Correct |
660 ms |
1760 KB |
Output is correct |
13 |
Correct |
714 ms |
1764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
348 KB |
Output is correct |
2 |
Correct |
25 ms |
344 KB |
Output is correct |
3 |
Correct |
126 ms |
716 KB |
Output is correct |
4 |
Correct |
307 ms |
744 KB |
Output is correct |
5 |
Correct |
672 ms |
1552 KB |
Output is correct |
6 |
Correct |
6 ms |
344 KB |
Output is correct |
7 |
Correct |
19 ms |
344 KB |
Output is correct |
8 |
Correct |
133 ms |
704 KB |
Output is correct |
9 |
Correct |
235 ms |
608 KB |
Output is correct |
10 |
Correct |
665 ms |
1400 KB |
Output is correct |
11 |
Correct |
662 ms |
1324 KB |
Output is correct |
12 |
Correct |
735 ms |
2056 KB |
Output is correct |
13 |
Correct |
674 ms |
1360 KB |
Output is correct |
14 |
Correct |
6 ms |
344 KB |
Output is correct |
15 |
Correct |
10 ms |
344 KB |
Output is correct |
16 |
Correct |
34 ms |
344 KB |
Output is correct |
17 |
Correct |
71 ms |
344 KB |
Output is correct |
18 |
Correct |
116 ms |
344 KB |
Output is correct |
19 |
Correct |
250 ms |
1112 KB |
Output is correct |
20 |
Correct |
240 ms |
1228 KB |
Output is correct |
21 |
Correct |
708 ms |
1988 KB |
Output is correct |
22 |
Correct |
723 ms |
1536 KB |
Output is correct |
23 |
Correct |
694 ms |
1860 KB |
Output is correct |
24 |
Correct |
673 ms |
1576 KB |
Output is correct |
25 |
Correct |
9 ms |
344 KB |
Output is correct |
26 |
Correct |
11 ms |
344 KB |
Output is correct |
27 |
Execution timed out |
2033 ms |
344 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
19 ms |
344 KB |
Output is correct |
3 |
Partially correct |
109 ms |
600 KB |
Output is partially correct |
4 |
Partially correct |
309 ms |
1236 KB |
Output is partially correct |
5 |
Partially correct |
742 ms |
1572 KB |
Output is partially correct |
6 |
Correct |
7 ms |
340 KB |
Output is correct |
7 |
Correct |
23 ms |
344 KB |
Output is correct |
8 |
Partially correct |
108 ms |
1112 KB |
Output is partially correct |
9 |
Partially correct |
246 ms |
1104 KB |
Output is partially correct |
10 |
Partially correct |
661 ms |
1376 KB |
Output is partially correct |
11 |
Partially correct |
623 ms |
1248 KB |
Output is partially correct |
12 |
Partially correct |
641 ms |
1104 KB |
Output is partially correct |
13 |
Partially correct |
618 ms |
1268 KB |
Output is partially correct |
14 |
Correct |
7 ms |
344 KB |
Output is correct |
15 |
Correct |
10 ms |
344 KB |
Output is correct |
16 |
Correct |
36 ms |
344 KB |
Output is correct |
17 |
Partially correct |
79 ms |
452 KB |
Output is partially correct |
18 |
Partially correct |
112 ms |
856 KB |
Output is partially correct |
19 |
Partially correct |
252 ms |
1128 KB |
Output is partially correct |
20 |
Partially correct |
274 ms |
1476 KB |
Output is partially correct |
21 |
Correct |
7 ms |
344 KB |
Output is correct |
22 |
Correct |
9 ms |
344 KB |
Output is correct |
23 |
Execution timed out |
2025 ms |
344 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |