| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 913464 | vjudge1 | Mouse (info1cup19_mouse) | C++17 | 55 ms | 1212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
int n;
int ask(const vector<int> &q) {
int x = query(q);
if (x == n) {
exit(0);
}
return x;
}
mt19937 rng(123123);
void solve(int n) {
::n = n;
vector<int> a(n);
iota(a.begin(), a.end(), 1);
int cur = ask(a);
for (int i = 0; i <= 0; i++) {
for (int j = i + 1; j < n; j++) {
swap(a[i], a[j]);
int tmp = ask(a);
if (tmp > cur) {
cur = tmp;
} else {
swap(a[i], a[j]);
}
}
}
vector<int> candidates;
for (int i = 1; i < n; i++) {
swap(a[i], a[0]);
int x = ask(a);
swap(a[i], a[0]);
if (cur - x == 2) continue;
candidates.emplace_back(i);
}
auto shift = [&](const vector<int> &v, bool invert = 0, bool answer = 1) {
vector<int> b(v.size());
for (int i = 0; i < v.size(); i++) b[i] = a[v[i]];
for (int i = 0; i < v.size(); i++) a[v[i]] = b[(i + 1) % v.size()];
int res = answer ? ask(a) : 0;
if (invert) {
for (int i = 0; i < v.size(); i++) a[v[i]] = b[i];
}
return res;
};
while (true) {
int diff = shift(candidates, 1) - cur;
if (diff == 0) {
shift(candidates, 0, 0);
continue;
}
int last = -1;
vector<int> good(candidates.size());
for (int d = 1; d <= diff; d++) {
int low = last + 1, high = candidates.size() - 1;
while (low < high) {
int mid = low + high >> 1;
vector<int> tmp;
for (int i = 0; i <= mid; i++) tmp.emplace_back(candidates[i]);
if (tmp.size() != candidates.size()) {
tmp.emplace_back(0);
tmp.emplace_back(candidates.back());
}
if (shift(tmp, 1) - cur >= d - (mid != candidates.size() ? 1 : 0)) {
high = mid;
} else {
low = mid + 1;
}
}
last = high;
good[(high + candidates.size() - 1) % candidates.size()] = 1;
}
shift(candidates, 0, 0);
vector<int> ncan;
for (int i = 0; i < candidates.size(); i++) {
if (!good[i]) ncan.emplace_back(candidates[i]);
}
ncan.swap(candidates);
cur += diff;
}
ask(a);
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
