QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#489736#8812. Library 3bambam#0 1ms4132kbC++171.2kb2024-07-24 23:55:522024-07-24 23:55:53

Judging History

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

  • [2024-07-24 23:55:53]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:4132kb
  • [2024-07-24 23:55:52]
  • 提交

answer

#include "library3.h"

#include <bits/stdc++.h>
using namespace std;

mt19937 rng(time(0));

void solve(int n) {
    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    int lst = query(p);
    for (int i = 1; i < n; ++i) {
        swap(p[0], p[i]);
        int cur = query(p);
        if (cur > lst) {
            lst = cur;
        } else {
            swap(p[0], p[i]);
        }
    }
    auto solve = [&](auto solve, vector<int> v) -> void {
        if (v.size() == 1) return;
        int id = rng() % (v.size() - 1) + 1;
        swap(p[v[0]], p[v[id]]);
        lst++;
        vector<int> lft, rgt;
        for (int i = 0; i < v.size(); ++i) {
            if (i == 0) lft.push_back(v[i]);
            else if (i == id) rgt.push_back(v[i]);
            else {
                swap(p[v[0]], p[v[i]]);
                int cur = query(p);
                swap(p[v[0]], p[v[i]]);
                if (cur < lst) lft.push_back(v[i]);
                else rgt.push_back(v[i]);
            }
        }
        solve(solve, lft);
        solve(solve, rgt);
    };
    vector<int> v(n);
    iota(v.begin(), v.end(), 0);
    solve(solve, v);
    answer(p);
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 2
Accepted
time: 0ms
memory: 4132kb

input:

2
0
1

output:

? 0 1
? 1 0
! 0 1
-

result:

ok Accepted

Test #2:

score: 2
Accepted
time: 0ms
memory: 3844kb

input:

3
2
1
1
0

output:

? 0 1 2
? 1 0 2
? 2 1 0
? 1 2 0
! 1 2 0
-

result:

ok Accepted

Test #3:

score: 0
Wrong Answer
time: 1ms
memory: 3916kb

input:

4
3
2
2
2
1
3
2

output:

? 0 1 2 3
? 1 0 2 3
? 2 1 0 3
? 3 1 2 0
? 1 2 0 3
? 3 1 0 2
? 1 3 0 2
! 1 3 0 2
-

result:

wrong answer Wrong Answer [8]

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%