//
// --- 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 <bits/stdc++.h>
#include "swaps.h"
using namespace std;
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
void solve(int N , int V) {
vector < int > v(N),ans;
iota(all(v),1);
while(sz(v)){
vector < int > curv = v , newv;
while(sz(curv) > 1){
newv.clear();
for(int i = 0;i<(sz(curv)-1);i+=2){
schedule(curv[i] , curv[i+1]);
}
vector < int > res = visit();
for(int i = 0;i<sz(res);i++){
newv.push_back(curv[2 * i + res[i]]);
}
if(sz(curv) & 1){
newv.push_back(curv.back());
}
curv = newv;
// cout << " curv : ";for(auto itr : curv)cout << itr << " ";cout << endl;
}
ans.push_back(curv[0]);
v.erase(find(all(v) , curv[0]));
// cout << "v : ";for(auto itr : v)cout << itr << " ";cout << endl;
// cout << "ans : ";for(auto itr : ans)cout << itr << " ";cout << endl;
// cout << endl;
}
reverse(all(ans));
answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Correct |
2 |
Correct |
4 ms |
440 KB |
Correct |
3 |
Correct |
19 ms |
468 KB |
Correct |
4 |
Correct |
54 ms |
704 KB |
Correct |
5 |
Correct |
49 ms |
696 KB |
Correct |
6 |
Correct |
46 ms |
708 KB |
Correct |
7 |
Correct |
45 ms |
952 KB |
Correct |
8 |
Correct |
43 ms |
700 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
4 ms |
436 KB |
Correct |
3 |
Correct |
17 ms |
464 KB |
Correct |
4 |
Correct |
45 ms |
696 KB |
Correct |
5 |
Correct |
43 ms |
692 KB |
Correct |
6 |
Correct |
43 ms |
704 KB |
Correct |
7 |
Correct |
44 ms |
1204 KB |
Correct |
8 |
Correct |
45 ms |
704 KB |
Correct |
9 |
Runtime error |
16 ms |
448 KB |
Execution killed with signal 13 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
4 ms |
608 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
4 ms |
608 KB |
Correct |
3 |
Correct |
1 ms |
344 KB |
Correct |
4 |
Correct |
3 ms |
608 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
4 ms |
608 KB |
Correct |
3 |
Correct |
15 ms |
468 KB |
Correct |
4 |
Correct |
49 ms |
952 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
4 ms |
608 KB |
Correct |
3 |
Correct |
15 ms |
468 KB |
Correct |
4 |
Correct |
49 ms |
952 KB |
Correct |
5 |
Correct |
0 ms |
344 KB |
Correct |
6 |
Correct |
4 ms |
440 KB |
Correct |
7 |
Correct |
15 ms |
460 KB |
Correct |
8 |
Correct |
43 ms |
452 KB |
Correct |
9 |
Correct |
44 ms |
948 KB |
Correct |
10 |
Correct |
43 ms |
704 KB |
Correct |
11 |
Correct |
45 ms |
452 KB |
Correct |
12 |
Correct |
46 ms |
700 KB |
Correct |
13 |
Correct |
0 ms |
344 KB |
Correct |
14 |
Correct |
4 ms |
608 KB |
Correct |
15 |
Correct |
14 ms |
464 KB |
Correct |
16 |
Correct |
43 ms |
472 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
3 ms |
608 KB |
Correct |
3 |
Correct |
14 ms |
692 KB |
Correct |
4 |
Correct |
45 ms |
456 KB |
Correct |
5 |
Runtime error |
8 ms |
696 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
3 ms |
608 KB |
Correct |
3 |
Correct |
14 ms |
692 KB |
Correct |
4 |
Correct |
45 ms |
456 KB |
Correct |
5 |
Runtime error |
8 ms |
696 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
3 ms |
608 KB |
Correct |
3 |
Correct |
14 ms |
464 KB |
Correct |
4 |
Correct |
48 ms |
700 KB |
Correct |
5 |
Runtime error |
8 ms |
696 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
3 ms |
608 KB |
Correct |
3 |
Correct |
14 ms |
464 KB |
Correct |
4 |
Correct |
48 ms |
700 KB |
Correct |
5 |
Runtime error |
8 ms |
696 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
4 ms |
612 KB |
Correct |
3 |
Correct |
16 ms |
468 KB |
Correct |
4 |
Correct |
46 ms |
948 KB |
Correct |
5 |
Runtime error |
8 ms |
444 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
4 ms |
612 KB |
Correct |
3 |
Correct |
16 ms |
468 KB |
Correct |
4 |
Correct |
46 ms |
948 KB |
Correct |
5 |
Runtime error |
8 ms |
444 KB |
Execution killed with signal 13 |
6 |
Halted |
0 ms |
0 KB |
- |