QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#745776 | #9432. Permutation | guosoun | RE | 0ms | 3828kb | C++17 | 1.9kb | 2024-11-14 11:31:38 | 2024-11-14 11:31:38 |
Judging History
answer
#include <bits/stdc++.h>
using ll = long long;
struct ia {
int query(std::vector<int> a) {
std::cout << 0 << ' ';
for (int i : a) std::cout << i << ' ';
std::cout << std::endl;
int ret;
std::cin >> ret;
return ret;
}
void answer(std::vector<int> a) {
std::cout << 1 << ' ';
for (int i : a) std::cout << i << ' ';
std::cout << std::endl;
}
} ia;
int main() {
std::cin.tie(0)->sync_with_stdio(0);
int n;
std::cin >> n;
if (n == 1) return ia.answer({1}), 0;
std::vector<int> a(n);
auto solve = [&](auto &self, int l, int r, std::vector<int> v) {
assert((int)v.size() == r - l + 1);
if (l == r) return a[l] = v[0], void();
int mid = (l + r) >> 1;
std::vector<std::vector<int>> cv;
std::vector<int> lv, rv;
for (int i : v) cv.push_back({i});
while (cv.size()) {
if (cv.size() == 1) {
auto a = cv[0];
cv.pop_back();
int v = a[0];
std::vector<int> q(n, !(v - 1) ? v + 1 : v - 1);
for (int i = l; i <= mid; i++) q[i] = v;
if (ia.query(q)) lv.insert(lv.end(), a.begin(), a.end());
else rv.insert(rv.end(), a.begin(), a.end());
continue;
}
auto a = cv.back();
cv.pop_back();
auto b = cv.back();
cv.pop_back();
std::vector<int> q(n, a[0]);
for (int i = mid + 1; i <= r; i++) q[i] = b[0];
if (int t = ia.query(q); t == 1) {
a.insert(a.end(), b.begin(), b.end());
cv.push_back(a);
} else if (t == 2) {
lv.insert(lv.end(), a.begin(), a.end());
rv.insert(rv.end(), b.begin(), b.end());
} else {
lv.insert(lv.end(), b.begin(), b.end());
rv.insert(rv.end(), a.begin(), a.end());
}
}
self(self, l, mid, lv);
self(self, mid + 1, r, rv);
};
std::vector<int> v(n);
std::iota(v.begin(), v.end(), 1);
solve(solve, 0, n - 1, v);
ia.answer(a);
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3828kb
input:
5 0 1 2 0 1 0 2
output:
0 5 5 5 4 4 0 3 3 3 2 2 0 3 3 3 1 1 0 2 2 3 2 2 0 4 4 3 3 3 0 4 3 4 4 4 0 1 1 1 1 5 1 3 4 2 1 5
result:
ok Accepted
Test #2:
score: -100
Runtime Error
input:
1000 2 1 1 1 0 1 1 0 1 1 0 2 1 0 1 2 1 1 1 2 1 1 2 1 2 1 1 1 2 2 2 2 1 0 0 1 1 2 2 0 1 1 0 0 0 0 1 0 1 2 2 1 2 1 1 1 2 0 0 2 1 2 0 1 2 0 0 1 0 0 2 0 0 0 2 0 1 0 1 0 2 1 1 1 0 1 1 1 2 1 1 0 2 1 0 0 1 0 0 1 2 0 0 1 1 1 2 0 1 1 1 0 1 1 1 1 2 1 0 1 1 2 1 1 0 1 1 0 1 1 1 1 1 1 1 1 0 0 0 1 1 2 0 1 2 0 0 2...
output:
0 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 100...