#include <bits/stdc++.h>
using namespace std;
bool are_connected(vector<int> A, vector<int> B);
vector<int> longest_trip(int n, int D)
{
bool con[n][n]={};
for (int i=1;i<n;i++)
for (int j=i+1;j<n;j++)
if (are_connected({i},{j}))
con[i][j]=con[j][i]=1;
vector<int> ans,lef;
ans.push_back(0);
for (int i=1;i<n;i++)
lef.push_back(i);
for (int ct=0;ct<n-2;ct++)
{
if (!are_connected({lef.back()},{ans.back()}))
swap(lef[n-2-ct],lef[n-2-ct-1]);
ans.push_back(lef.back());
lef.pop_back();
}
if (!are_connected({lef.back()},{ans.back()}))
swap(ans[n-2],ans[n-3]);
ans.push_back(lef[0]);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
17 ms |
344 KB |
Output is correct |
3 |
Correct |
181 ms |
344 KB |
Output is correct |
4 |
Correct |
392 ms |
344 KB |
Output is correct |
5 |
Correct |
866 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
22 ms |
344 KB |
Output is correct |
3 |
Correct |
139 ms |
344 KB |
Output is correct |
4 |
Correct |
396 ms |
344 KB |
Output is correct |
5 |
Correct |
837 ms |
596 KB |
Output is correct |
6 |
Correct |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
22 ms |
344 KB |
Output is correct |
8 |
Correct |
158 ms |
344 KB |
Output is correct |
9 |
Correct |
289 ms |
340 KB |
Output is correct |
10 |
Correct |
855 ms |
476 KB |
Output is correct |
11 |
Correct |
854 ms |
476 KB |
Output is correct |
12 |
Correct |
861 ms |
472 KB |
Output is correct |
13 |
Correct |
835 ms |
476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
19 ms |
344 KB |
Output is correct |
3 |
Correct |
175 ms |
344 KB |
Output is correct |
4 |
Correct |
440 ms |
344 KB |
Output is correct |
5 |
Correct |
886 ms |
472 KB |
Output is correct |
6 |
Correct |
7 ms |
344 KB |
Output is correct |
7 |
Correct |
15 ms |
340 KB |
Output is correct |
8 |
Correct |
149 ms |
344 KB |
Output is correct |
9 |
Correct |
320 ms |
344 KB |
Output is correct |
10 |
Correct |
808 ms |
476 KB |
Output is correct |
11 |
Correct |
844 ms |
476 KB |
Output is correct |
12 |
Correct |
861 ms |
476 KB |
Output is correct |
13 |
Correct |
835 ms |
468 KB |
Output is correct |
14 |
Incorrect |
0 ms |
344 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
22 ms |
344 KB |
Output is correct |
3 |
Partially correct |
145 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
428 ms |
344 KB |
Output is partially correct |
5 |
Partially correct |
864 ms |
596 KB |
Output is partially correct |
6 |
Correct |
9 ms |
344 KB |
Output is correct |
7 |
Correct |
21 ms |
344 KB |
Output is correct |
8 |
Partially correct |
154 ms |
344 KB |
Output is partially correct |
9 |
Partially correct |
334 ms |
344 KB |
Output is partially correct |
10 |
Partially correct |
864 ms |
476 KB |
Output is partially correct |
11 |
Partially correct |
859 ms |
472 KB |
Output is partially correct |
12 |
Partially correct |
873 ms |
476 KB |
Output is partially correct |
13 |
Partially correct |
876 ms |
476 KB |
Output is partially correct |
14 |
Incorrect |
0 ms |
344 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |