Submission #913088

# Submission time Handle Problem Language Result Execution time Memory
913088 2024-01-20T05:53:55 Z vjudge1 Mouse (info1cup19_mouse) C++17
40.6667 / 100
101 ms 604 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);
        do {
                shuffle(a.begin(), a.end(), rng);
        } while (ask(a));
        int cur = 0;
        vector<int> done(n);
        for (int i = 0; i < n; i++) {
                vector<int> ord;
                for (int j = i + 1; j < n; 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
                                if (might_done == 0) done[j] = 1;
                                swap(a[i], a[j]);
                        } else {
                                done[j] = 1;
                                swap(a[i], a[j]);
                                break;
                        }
                }
        }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct! Number of queries: 23
2 Correct 1 ms 492 KB Correct! Number of queries: 6
3 Correct 1 ms 344 KB Correct! Number of queries: 13
4 Correct 1 ms 344 KB Correct! Number of queries: 13
5 Correct 1 ms 340 KB Correct! Number of queries: 14
6 Correct 1 ms 344 KB Correct! Number of queries: 12
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct! Number of queries: 23
2 Correct 1 ms 492 KB Correct! Number of queries: 6
3 Correct 1 ms 344 KB Correct! Number of queries: 13
4 Correct 1 ms 344 KB Correct! Number of queries: 13
5 Correct 1 ms 340 KB Correct! Number of queries: 14
6 Correct 1 ms 344 KB Correct! Number of queries: 12
7 Correct 5 ms 344 KB Correct! Number of queries: 700
8 Correct 7 ms 344 KB Correct! Number of queries: 700
9 Correct 4 ms 596 KB Correct! Number of queries: 600
10 Correct 6 ms 344 KB Correct! Number of queries: 700
11 Correct 4 ms 344 KB Correct! Number of queries: 500
12 Correct 5 ms 344 KB Correct! Number of queries: 700
13 Correct 6 ms 344 KB Correct! Number of queries: 700
14 Correct 7 ms 344 KB Correct! Number of queries: 800
15 Correct 6 ms 344 KB Correct! Number of queries: 700
16 Correct 6 ms 504 KB Correct! Number of queries: 700
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct! Number of queries: 23
2 Correct 1 ms 492 KB Correct! Number of queries: 6
3 Correct 1 ms 344 KB Correct! Number of queries: 13
4 Correct 1 ms 344 KB Correct! Number of queries: 13
5 Correct 1 ms 340 KB Correct! Number of queries: 14
6 Correct 1 ms 344 KB Correct! Number of queries: 12
7 Correct 5 ms 344 KB Correct! Number of queries: 700
8 Correct 7 ms 344 KB Correct! Number of queries: 700
9 Correct 4 ms 596 KB Correct! Number of queries: 600
10 Correct 6 ms 344 KB Correct! Number of queries: 700
11 Correct 4 ms 344 KB Correct! Number of queries: 500
12 Correct 5 ms 344 KB Correct! Number of queries: 700
13 Correct 6 ms 344 KB Correct! Number of queries: 700
14 Correct 7 ms 344 KB Correct! Number of queries: 800
15 Correct 6 ms 344 KB Correct! Number of queries: 700
16 Correct 6 ms 504 KB Correct! Number of queries: 700
17 Runtime error 101 ms 604 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -