#include "chameleon.h"
#include <vector>
#include <bitset>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
void Solve(int N) {
//cout << Query({1, 3, 4, 7}) << '\n';
//cout << Query({1, 2, 3, 4, 5, 6, 7, 8}) << '\n';
//cout << Query({3, 4, 5, 6, 7, 8}) << '\n';
//cout << Query({2, 3, 4, 5, 6, 8}) << '\n';
//cout << Query({2, 3, 4, 5, 6, 7}) << '\n';
//cout << Query({2, 3, 4, 5, 7, 8}) << '\n';
//cout << Query({2, 3, 4, 5, 7}) << '\n';
bitset<1001> found;
vector<int> counts(2*N+1, 3);
map<vector<int>, int> pre_calc;
for(int i=1; i<=2*N; i++) {
vector<int> tests;
if(found[i])
continue;
for(int j=2*N; j>0; j--) {
if(found[j] || i == j)
continue;
if(pre_calc[{i, j}] == 0)
pre_calc[{i, j}] = Query({i, j});
if(pre_calc[{i, j}] == 1) {
tests.push_back(j);
counts[j]--;
}
if(tests.size() == counts[i])
break;
}
vector<int> check_same[counts[i]];
for(int j=1; j<=2*N; j++) {
if(i == j)
continue;
for(int k=0; k<counts[i]; k++) {
if(tests[k] != j)
check_same[k].push_back(j);
}
}
vector<int> results;
for(int k=0; k<counts[i]; k++) {
if(pre_calc[check_same[k]] == 0)
pre_calc[check_same[k]] = Query(check_same[k]);
results.push_back(pre_calc[check_same[k]]);
}
int same = min_element(results.begin(), results.end()) - results.begin();
same = tests[same];
found[i] = 1;
found[same] = 1;
counts[same] = 0;
counts[i] = 0;
Answer(i, same);
}
}
| # | 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... |