Submission #970424

#TimeUsernameProblemLanguageResultExecution timeMemory
970424NotLinuxThe Collection Game (BOI21_swaps)C++17
25 / 100
54 ms1204 KiB
//
// --- 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...