#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
void N_less_or_equal_100(const int N) {
	vector<bool> known(2*N+1, false);
	int in_device = 0;
	int cnt_pairs = 0;
	for (int i=1; i<=2*N; i++) if (!known[i]) {
		// szukamy pary dla i
		in_device = Query(i); // wrzucamy i do maszyny
		for (int j=i+1; j<=2*N; j++) if (!known[j]) {
			in_device = Query(j); // wrzucamy j do maszyny
			if (in_device == 1 + cnt_pairs) {
				known[i] = true;
				known[j] = true;
				Answer(i,j);
				cnt_pairs++;
				break;
			}
			in_device = Query(j); // wyciągamy j z maszyny
		}
	}
}
void N_less_or_equal_15e3_first_X_second_Y(const int N) {
	vector<bool> known(2*N+1, false);
	int in_device = 0;
	int cnt_pairs = 0;
	for (int i=1; i<=N; i++) if (!known[i]) {
		// szukamy pary dla i
		in_device = Query(i); // wrzucamy i do maszyny
		for (int j=N+1; j<=2*N; j++) if (!known[j]) {
			in_device = Query(j); // wrzucamy j do maszyny
			if (in_device == 1 + cnt_pairs) {
				known[i] = true;
				known[j] = true;
				Answer(i,j);
				cnt_pairs++;
				break;
			}
			in_device = Query(j); // wyciągamy j z maszyny
		}
	}
}
void Solve(int N) {
	if (N <= 100) { N_less_or_equal_100(N); return; }
	N_less_or_equal_15e3_first_X_second_Y(N);
}
| # | 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... |