This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// --- 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);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |