Submission #913110

# Submission time Handle Problem Language Result Execution time Memory
913110 2024-01-20T06:04:15 Z vjudge1 Mouse (info1cup19_mouse) C++17
0 / 100
1 ms 596 KB
#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);
        shuffle(a.begin(), a.end(), rng);
        int cur = ask(a);
        vector<int> done(n);
        for (int i = 0; i < n; i++) {
                if (done[i]) continue;
                swap(a[0], a[i]);
                int x = ask(a);
                swap(a[0], a[i]);
                if (x == cur - 2) {
                        continue;
                }
                vector<int> ord;
                for (int j = i + 1; j < n; j++) {
                        if (!done[j]) ord.emplace_back(j);
                }
                shuffle(ord.begin(), ord.end(), rng);
                bool might_done = 0;
                int last_done = -1;
                for (int j : ord) {
                        swap(a[i], a[j]);
                        int tmp = ask(a);
                        if (tmp - cur == 2) {
                                done[j] = 1;
                                cur = tmp;
                                break;
                        } else if (tmp - cur == 1) {
                                cur = tmp;
                                // a[i] = j || a[j] = i
                                if (might_done) done[last_done] = 1;
                                might_done = 1;
                                last_done = j;
                        } else if (tmp == cur) {
                                // a[i] != j && a[i] != i && a[j] != i && a[j] != j
                                if (might_done) done[last_done] = 1;
                                might_done = 0;
                                swap(a[i], a[j]);
                        } else if (tmp - cur == -1) {  // tmp < cur
                                // a[i] = i || a[j] = j
                                swap(a[i], a[j]);
                                if (might_done == 0) {
                                        done[j] = 1;
                                } else {
                                        break;
                                }
                        } else {
                                done[j] = 1;
                                swap(a[i], a[j]);
                                break;
                        }
                }
        }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 596 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 596 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 596 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -