Submission #401110

# Submission time Handle Problem Language Result Execution time Memory
401110 2021-05-09T11:32:33 Z dolphingarlic Mouse (info1cup19_mouse) C++14
35.3333 / 100
223 ms 200 KB
#include "grader.h"

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

// int n;
// vector<int> p;
// bool success = false;
// int queries = 0;

// int query(vector<int> q) {
//     queries++;
//     int cnt = 0;
//     for (int i = 0; i < n; i++) cnt += p[i] == q[i];
//     if (cnt == n) success = true;
//     return cnt;
// }

void solve(int N) {
    srand(69420);
    vector<int> perm(N), pot(N);
    iota(perm.begin(), perm.end(), 1);
    vector<bool> known(N, false);
    int prv = -1;
    for (int i = 0; i < N;) {
        if (known[i]) {
            i++;
            continue;
        }
        int baseline = query(perm);
        if (baseline == N) return;

        int found = -1;
        for (int j = i + 1; j < N; j++) if (!known[j]) {
            swap(perm[i], perm[j]);
            pot[j] = query(perm);
            if (pot[j] == N) return;
            if (pot[j] > baseline) {
                found = j;
                break;
            }
            swap(perm[i], perm[j]);
        }
        if (~found) {
            for (int j = i + 1; j < N; j++) {
                if (pot[j] > baseline) break;
                if (!known[j] && pot[j] < baseline) known[j] = true;
            }
            if (~prv) known[prv] = true;
            prv = found;
        } else {
            for (int j = i + 1; j < N; j++) {
                if (pot[j] > baseline) break;
                if (!known[j] && pot[j] == baseline - 2) known[j] = true;
            }
            known[i] = true;
            i++;
            prv = -1;
        }
    }
    query(perm);
}

// int main() {
//     cin >> n;
//     p.resize(n);
//     for (int i = 0; i < n; i++) cin >> p[i];
//     solve(n);
//     if (success) {
//         cout << "Found the permutation after " << queries << " queries";
//     } else {
//         cout << "Wrong answer";
//     }
// }
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Correct! Number of queries: 24
2 Correct 1 ms 200 KB Correct! Number of queries: 12
3 Correct 1 ms 200 KB Correct! Number of queries: 22
4 Correct 1 ms 200 KB Correct! Number of queries: 27
5 Correct 1 ms 200 KB Correct! Number of queries: 27
6 Correct 1 ms 200 KB Correct! Number of queries: 24
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Correct! Number of queries: 24
2 Correct 1 ms 200 KB Correct! Number of queries: 12
3 Correct 1 ms 200 KB Correct! Number of queries: 22
4 Correct 1 ms 200 KB Correct! Number of queries: 27
5 Correct 1 ms 200 KB Correct! Number of queries: 27
6 Correct 1 ms 200 KB Correct! Number of queries: 24
7 Correct 14 ms 200 KB Correct! Number of queries: 800
8 Correct 14 ms 200 KB Correct! Number of queries: 900
9 Correct 18 ms 200 KB Correct! Number of queries: 1000
10 Correct 24 ms 200 KB Correct! Number of queries: 1200
11 Correct 13 ms 200 KB Correct! Number of queries: 700
12 Correct 19 ms 200 KB Correct! Number of queries: 1000
13 Correct 17 ms 200 KB Correct! Number of queries: 900
14 Correct 15 ms 200 KB Correct! Number of queries: 900
15 Correct 17 ms 200 KB Correct! Number of queries: 1100
16 Correct 14 ms 200 KB Correct! Number of queries: 1000
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Correct! Number of queries: 24
2 Correct 1 ms 200 KB Correct! Number of queries: 12
3 Correct 1 ms 200 KB Correct! Number of queries: 22
4 Correct 1 ms 200 KB Correct! Number of queries: 27
5 Correct 1 ms 200 KB Correct! Number of queries: 27
6 Correct 1 ms 200 KB Correct! Number of queries: 24
7 Correct 14 ms 200 KB Correct! Number of queries: 800
8 Correct 14 ms 200 KB Correct! Number of queries: 900
9 Correct 18 ms 200 KB Correct! Number of queries: 1000
10 Correct 24 ms 200 KB Correct! Number of queries: 1200
11 Correct 13 ms 200 KB Correct! Number of queries: 700
12 Correct 19 ms 200 KB Correct! Number of queries: 1000
13 Correct 17 ms 200 KB Correct! Number of queries: 900
14 Correct 15 ms 200 KB Correct! Number of queries: 900
15 Correct 17 ms 200 KB Correct! Number of queries: 1100
16 Correct 14 ms 200 KB Correct! Number of queries: 1000
17 Runtime error 223 ms 200 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -