| #include <iostream> |
| #include <vector> |
| #include <numeric> |
| #include <algorithm> |
|
|
| |
| int ask(int n, const std::vector<int>& q) { |
| std::cout << 0; |
| for (int i = 0; i < n; ++i) { |
| std::cout << " " << q[i]; |
| } |
| std::cout << std::endl; |
| int x; |
| std::cin >> x; |
| |
| if (x == -1) { |
| exit(0); |
| } |
| return x; |
| } |
|
|
| |
| void guess(int n, const std::vector<int>& p) { |
| std::cout << 1; |
| for (int i = 0; i < n; ++i) { |
| std::cout << " " << p[i]; |
| } |
| std::cout << std::endl; |
| } |
|
|
| int main() { |
| std::ios_base::sync_with_stdio(false); |
| std::cin.tie(NULL); |
|
|
| int n; |
| std::cin >> n; |
|
|
| std::vector<int> p(n); |
| std::vector<bool> used(n + 1, false); |
| |
| |
| |
| |
| std::vector<int> q(n); |
| std::iota(q.begin(), q.end(), 1); |
|
|
| |
| for (int i = n - 1; i >= 0; --i) { |
| |
| std::vector<int> unused_values; |
| for (int j = 1; j <= n; ++j) { |
| if (!used[j]) { |
| unused_values.push_back(j); |
| } |
| } |
| |
| |
| if (unused_values.size() == 1) { |
| p[i] = unused_values[0]; |
| used[p[i]] = true; |
| q[i] = p[i]; |
| continue; |
| } |
|
|
| int best_val = -1; |
| |
| |
| int base_val = unused_values[0]; |
| q[i] = base_val; |
| int base_matches = ask(n, q); |
|
|
| bool found_better = false; |
| |
| for (size_t j = 1; j < unused_values.size(); ++j) { |
| int current_val = unused_values[j]; |
| q[i] = current_val; |
| int current_matches = ask(n, q); |
| |
| if (current_matches > base_matches) { |
| best_val = current_val; |
| found_better = true; |
| break; |
| } |
| } |
| |
| |
| if (!found_better) { |
| best_val = base_val; |
| } |
|
|
| p[i] = best_val; |
| used[p[i]] = true; |
| |
| q[i] = p[i]; |
| } |
|
|
| guess(n, p); |
|
|
| return 0; |
| } |