#include "minerals.h"
	#include <bits/stdc++.h>
	using namespace std;
	void Solve(int N) {
		 srand(2137);
		 vector<int> indeksy;
		 vector<int> indeksy2;
		 for (int i = 1; i <= N; i++)
			indeksy.push_back(i);
		 for (int i = N+1; i <= 2*N; i++){
			 indeksy2.push_back(i);
		 }	
		int prev = 0;
		vector<int> wmaszynie;
		int kand = 0;
		int ilepar = 0;
		random_shuffle(indeksy.begin(), indeksy.end());
		random_shuffle(indeksy2.begin(), indeksy2.end());
		int tura = 0;
		while (indeksy.size() || indeksy2.size()){
			if (!indeksy.size() || (tura && indeksy2.size())) swap(indeksy, indeksy2);
			tura ^= 1;
			int nowe = Query(indeksy.back());
			//cerr << nowe << " " << prev << "\n";
			kand = indeksy.back();
			indeksy.pop_back();
			if (nowe == prev){
				//cerr << "wtf\n";
				while (wmaszynie.size()){
					nowe = Query(wmaszynie.back());
					if (nowe == prev){
						Answer(wmaszynie.back(), kand);
						prev = Query(kand);
						wmaszynie.pop_back();
						if (indeksy.size() && ilepar == 50 + rand()%1 ){
							random_shuffle(indeksy.begin(), indeksy.end());
							ilepar = 0;
						}
						ilepar++;
						break;
						}
					prev = nowe;
					indeksy.push_back(wmaszynie.back());
					wmaszynie.pop_back();
				}
			}
			else{
				prev = nowe;
				wmaszynie.push_back(kand);
			}
		}
	}
| # | 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... |