//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
// swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include "swaps.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define vb vector<bool>
#define vi vector<int>
#define vpii vector<pii>
#define vvb vector<vb>
#define vvi vector<vi>
#define vvpii vector<vpii>
#define sz(x) (int)(x).size()
int N, V;
void solve(int _N, int _V)
{
N = _N, V = _V;
vvi ans(N);
vi todo;
for (int i = 1; i <= N; ++i)
todo.push_back(i);
ans[0].push_back(todo.back()), todo.pop_back();
if (N > 1)
ans[0].push_back(todo.back()), todo.pop_back();
while (sz(ans.back()) == 0)
{
for (int i = 0; i < N; ++i)
if (sz(ans[i]) > 1)
schedule(ans[i][0], ans[i][1]);
vi v = visit();
for (int i = N - 1; i >= 0; --i)
if (sz(ans[i]) > 1)
{
if (!v.back())
swap(ans[i][0], ans[i][1]);
v.pop_back();
}
for (int i = N - 2; i >= 0; --i)
if (sz(ans[i]) > 1)
ans[i + 1].push_back(ans[i].back()), ans[i].pop_back();
if (sz(todo) > 0)
ans[0].push_back(todo.back()), todo.pop_back();
}
vi formalAns;
for (int i = 0; i < N; ++i)
formalAns.push_back(ans[i][0]);
answer(formalAns);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
5 ms |
304 KB |
Correct |
3 |
Correct |
13 ms |
340 KB |
Correct |
4 |
Correct |
55 ms |
408 KB |
Correct |
5 |
Correct |
46 ms |
340 KB |
Correct |
6 |
Correct |
46 ms |
336 KB |
Correct |
7 |
Correct |
43 ms |
340 KB |
Correct |
8 |
Correct |
45 ms |
344 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
4 ms |
208 KB |
Correct |
3 |
Correct |
15 ms |
304 KB |
Correct |
4 |
Correct |
49 ms |
336 KB |
Correct |
5 |
Correct |
47 ms |
468 KB |
Correct |
6 |
Correct |
51 ms |
336 KB |
Correct |
7 |
Correct |
47 ms |
332 KB |
Correct |
8 |
Correct |
47 ms |
336 KB |
Correct |
9 |
Correct |
46 ms |
336 KB |
Correct |
10 |
Correct |
44 ms |
340 KB |
Correct |
11 |
Correct |
46 ms |
416 KB |
Correct |
12 |
Correct |
47 ms |
336 KB |
Correct |
13 |
Correct |
51 ms |
348 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
4 ms |
208 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
4 ms |
208 KB |
Correct |
3 |
Correct |
1 ms |
208 KB |
Correct |
4 |
Correct |
4 ms |
208 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
3 ms |
208 KB |
Correct |
3 |
Correct |
14 ms |
312 KB |
Correct |
4 |
Correct |
47 ms |
340 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
3 ms |
208 KB |
Correct |
3 |
Correct |
14 ms |
312 KB |
Correct |
4 |
Correct |
47 ms |
340 KB |
Correct |
5 |
Correct |
1 ms |
208 KB |
Correct |
6 |
Correct |
3 ms |
304 KB |
Correct |
7 |
Correct |
13 ms |
304 KB |
Correct |
8 |
Correct |
47 ms |
392 KB |
Correct |
9 |
Correct |
64 ms |
344 KB |
Correct |
10 |
Correct |
47 ms |
340 KB |
Correct |
11 |
Correct |
44 ms |
332 KB |
Correct |
12 |
Correct |
41 ms |
464 KB |
Correct |
13 |
Correct |
1 ms |
208 KB |
Correct |
14 |
Correct |
5 ms |
336 KB |
Correct |
15 |
Correct |
16 ms |
320 KB |
Correct |
16 |
Correct |
49 ms |
332 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
4 ms |
336 KB |
Correct |
3 |
Correct |
19 ms |
308 KB |
Correct |
4 |
Correct |
47 ms |
332 KB |
Correct |
5 |
Runtime error |
25 ms |
536 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
4 ms |
336 KB |
Correct |
3 |
Correct |
19 ms |
308 KB |
Correct |
4 |
Correct |
47 ms |
332 KB |
Correct |
5 |
Runtime error |
25 ms |
536 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
4 ms |
208 KB |
Correct |
3 |
Correct |
13 ms |
208 KB |
Correct |
4 |
Correct |
52 ms |
456 KB |
Correct |
5 |
Runtime error |
24 ms |
420 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
4 ms |
208 KB |
Correct |
3 |
Correct |
13 ms |
208 KB |
Correct |
4 |
Correct |
52 ms |
456 KB |
Correct |
5 |
Runtime error |
24 ms |
420 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
3 ms |
208 KB |
Correct |
3 |
Correct |
13 ms |
308 KB |
Correct |
4 |
Correct |
44 ms |
332 KB |
Correct |
5 |
Runtime error |
26 ms |
448 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct |
2 |
Correct |
3 ms |
208 KB |
Correct |
3 |
Correct |
13 ms |
308 KB |
Correct |
4 |
Correct |
44 ms |
332 KB |
Correct |
5 |
Runtime error |
26 ms |
448 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |