QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#655016#9432. Permutationonly3WA 0ms3864kbC++141.5kb2024-10-18 23:46:382024-10-18 23:46:38

Judging History

你现在查看的是最新测评结果

  • [2024-10-18 23:46:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3864kb
  • [2024-10-18 23:46:38]
  • 提交

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;
    cout << "0 ";
    for (int x : vec)
        cout << x << ' ';
    cout << endl;
    int resp;
    cin >> resp;
    return resp;
}

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 += 2)
    {
        vector<int> vq(n);
        for (int j = 0; j < n; ++j)
            vq[j] = vec[0];
        for (int j = l; j <= r; ++j)
            vq[j - 1] = vec[i / 2];

        int resp = query(vq);
        if (resp == 2)
        {
            vr.push_back(vec[i / 2]);
        }
        else if (resp == 0)
        {
            vl.push_back(vec[i / 2]);
        }
        else
        {
            vl.push_back(vec[i / 2]);
            vr.push_back(vec[i / 2]);
        }
    }
    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);
    for (int i = 0; i < n; ++i)
        vec[i] = i + 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: 0ms
memory: 3864kb

input:

5
1
1
1
1
1
1
1
0

output:

0 2 2 2 2 2 
0 1 1 1 1 1 
0 5 5 5 5 5 
0 1 1 1 1 1 
0 5 5 5 1 1 
0 1 1 1 1 1 
0 1 1 1 1 1 
0 1 1 1 2 2 
1 1 1 1 1 1 

result:

wrong answer Wrong Anser