Submission #679823

# Submission time Handle Problem Language Result Execution time Memory
679823 2023-01-09T11:14:40 Z bashkort Monster Game (JOI21_monster) C++17
0 / 100
159 ms 312 KB
#include "monster.h"
#include <bits/stdc++.h>

using namespace std;

mt19937 rnd(228);

vector<int> Solve(int n) {
    vector<int> ord(n);
    iota(ord.begin(), ord.end(), 0);

    shuffle(ord.begin(), ord.end(), rnd);

    stable_sort(ord.begin(), ord.end(), [&](int i, int j) {
        return !Query(i, j);
    });

    int k = min(n, 10);

    vector<int> win(k);

    for (int i = 0; i < k; ++i) {
        for (int j = i + 1; j < k; ++j) {
            if (Query(i, j)) {
                win[i] += 1;
            } else {
                win[j] += 1;
            }
        }
    }

    int fi = min_element(win.begin(), win.end()) - win.begin();
    int se = min_element(win.begin() + fi + 1, win.end()) - win.begin();

    int x = Query(fi, se) ? fi : se;

    rotate(ord.begin(), ord.begin() + x, ord.begin() + x + 1);

    x = 0;

    for (int i = 1, j = 1; i < n; i = j) {
        while (Query(ord[j], ord[x])) {
            j += 1;
        }

        reverse(ord.begin() + i, ord.begin() + j);

        x = j - 1;
    }

    vector<int> ans(n);
    for (int i = 0; i < n; ++i) {
        ans[ord[i]] = i;
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 296 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 296 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 159 ms 312 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -