QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#655013 | #9432. Permutation | only3 | WA | 1ms | 3732kb | C++14 | 1.6kb | 2024-10-18 23:44:52 | 2024-10-18 23:44:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int ans[1010], n, tot = 0;
int query(const vector<int> &vec)
{
++tot;
int ret = 0;
for (int i = 1; i <= n; ++i)
{
if (vec[i - 1] == i)
++ret;
}
return ret;
}
void solve(int l, int r, vector<int> vec)
{
if (l == r)
{
ans[l] = vec[0];
return;
}
shuffle(vec.begin(), vec.end(), rng);
int mid = (l + r) / 2;
vector<int> vl, vr;
for (int i = 0; i < vec.size(); ++i)
{
vector<int> vq(n);
fill(vq.begin(), vq.end(), vec[i]);
for (int j = l; j <= r; ++j)
{
vq[j - 1] = vec[i ^ 1]; // 切换元素位置
}
cout << "0 ";
for (auto x : vq)
cout << x << ' ';
cout << endl;
int resp;
cin >> resp;
if (resp == 2)
{
vr.push_back(vec[i]);
}
else if (!resp)
{
vl.push_back(vec[i]);
}
else
{ // resp == 1
vl.push_back(vec[i ^ 1]);
vr.push_back(vec[i]);
}
}
solve(l, mid, vl);
solve(mid + 1, r, vr);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
vector<int> vec(n);
iota(vec.begin(), vec.end(), 1);
solve(1, n, vec);
cout << "1 ";
for (int i = 1; i <= n; ++i)
{
cout << ans[i] << ' ';
}
cout << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3732kb
input:
5 1 1 1 1
output:
0 2 2 2 2 2 0 4 4 4 4 4 0 3 3 3 3 3 0 1 1 1 1 1 0 0 0 0 0 0
result:
wrong answer Integer element [index=1] equals to 0, violates the range [1, 5]