Submission #1361228

#TimeUsernameProblemLanguageResultExecution timeMemory
1361228ezdpSuper Dango Maker (JOI22_dango3)C++20
7 / 100
121 ms664 KiB
#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;

void Solve(int n, int m){
	vector<int> candidates(n * m);
	iota(candidates.begin(), candidates.end(), 1);
	while(!candidates.empty()){
		int low = 0, high = candidates.size() - 1, ans = -1;
		while(low <= high){
			int mid = (low + high) / 2;
			vector<int> qry(candidates.begin(), candidates.begin() + mid + 1);
			if(Query(qry) > 0){
				high = mid - 1;
			}
			else{
				ans = mid + 1;
				low = mid + 1;
			}
		}
		vector<int> current_dango(candidates.begin(), candidates.begin() + ans + 1);
		for(int i = current_dango.size() - 2; i >= 0; i --){
			swap(current_dango.back(), current_dango[i]);
			int save = current_dango.back();
			current_dango.pop_back();
			if(Query(current_dango) == 0){
				current_dango.push_back(save);
			}
		}
		
		Answer(current_dango);
		sort(current_dango.begin(), current_dango.end());
		
		vector<int> new_candidates;
		for(int i = candidates.size() - 1; i >= 0; i --){
			if(current_dango.back() != candidates[i]){
				new_candidates.push_back(candidates[i]);
			}
			else{
				current_dango.pop_back();
			}
		}
		reverse(new_candidates.begin(), new_candidates.end());
		candidates = new_candidates;
	}
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...