#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
const int nx=305;
int qrs[nx][nx];
int query(int i, int j)
{
if (i>j) swap(i, j);
return qrs[i][j];
}
std::vector<int> longest_trip(int N, int D)
{
for (int i=0; i<N; i++) for (int j=i+1; j<N; j++) qrs[i][j]=are_connected(vector<int> {i}, vector<int> {j});
deque<int> dq;
for (int i=0; i<N; i++) dq.push_back(i);
for (int i=0; i<N-2; i++) if (!query(dq[i], dq[i+1])) swap(dq[i+1], dq[i+2]);
if (!query(dq[N-2], dq[N-1])) dq.pop_front(), dq.push_back(0), swap(dq.back(), dq[dq.size()-2]);
vector<int> res;
for (int i=0; i<N; i++) res.push_back(dq[i]);
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
24 ms |
344 KB |
Output is correct |
3 |
Correct |
126 ms |
1112 KB |
Output is correct |
4 |
Correct |
345 ms |
1516 KB |
Output is correct |
5 |
Correct |
773 ms |
1444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
23 ms |
344 KB |
Output is correct |
3 |
Correct |
130 ms |
1368 KB |
Output is correct |
4 |
Correct |
344 ms |
1116 KB |
Output is correct |
5 |
Correct |
719 ms |
1580 KB |
Output is correct |
6 |
Correct |
7 ms |
596 KB |
Output is correct |
7 |
Correct |
20 ms |
344 KB |
Output is correct |
8 |
Correct |
128 ms |
856 KB |
Output is correct |
9 |
Correct |
274 ms |
1012 KB |
Output is correct |
10 |
Correct |
747 ms |
1548 KB |
Output is correct |
11 |
Correct |
733 ms |
1312 KB |
Output is correct |
12 |
Correct |
719 ms |
1376 KB |
Output is correct |
13 |
Correct |
751 ms |
1840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
28 ms |
340 KB |
Output is correct |
3 |
Correct |
140 ms |
720 KB |
Output is correct |
4 |
Correct |
364 ms |
1520 KB |
Output is correct |
5 |
Correct |
754 ms |
1892 KB |
Output is correct |
6 |
Correct |
8 ms |
344 KB |
Output is correct |
7 |
Correct |
21 ms |
344 KB |
Output is correct |
8 |
Correct |
136 ms |
856 KB |
Output is correct |
9 |
Correct |
267 ms |
1516 KB |
Output is correct |
10 |
Correct |
725 ms |
1588 KB |
Output is correct |
11 |
Correct |
762 ms |
1288 KB |
Output is correct |
12 |
Correct |
726 ms |
1836 KB |
Output is correct |
13 |
Correct |
751 ms |
1968 KB |
Output is correct |
14 |
Incorrect |
0 ms |
344 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
2 |
Correct |
26 ms |
344 KB |
Output is correct |
3 |
Partially correct |
127 ms |
600 KB |
Output is partially correct |
4 |
Partially correct |
335 ms |
956 KB |
Output is partially correct |
5 |
Partially correct |
737 ms |
1796 KB |
Output is partially correct |
6 |
Correct |
6 ms |
344 KB |
Output is correct |
7 |
Correct |
21 ms |
344 KB |
Output is correct |
8 |
Partially correct |
111 ms |
856 KB |
Output is partially correct |
9 |
Partially correct |
276 ms |
1740 KB |
Output is partially correct |
10 |
Partially correct |
715 ms |
2044 KB |
Output is partially correct |
11 |
Partially correct |
709 ms |
1896 KB |
Output is partially correct |
12 |
Partially correct |
729 ms |
1900 KB |
Output is partially correct |
13 |
Partially correct |
760 ms |
1408 KB |
Output is partially correct |
14 |
Incorrect |
0 ms |
344 KB |
Incorrect |
15 |
Halted |
0 ms |
0 KB |
- |