답안 #679828

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
679828 2023-01-09T11:40:25 Z bashkort Monster Game (JOI21_monster) C++17
98 / 100
111 ms 1700 KB
#include "monster.h"
#include <bits/stdc++.h>

using namespace std;


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

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


    map<pair<int, int>, bool> asked;
    auto ask = [&](int i, int j) {
        if (!asked.count({i, j})) {
            asked[{i, j}] = Query(i, j);
            asked[{j, i}] = !asked[{i, j}];
        }
        return asked[{i, j}];
    };
    
    stable_sort(ord.begin(), ord.end(), [&](int i, int j) {
        return !ask(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 (ask(ord[i], ord[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 = ask(ord[fi], ord[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 (ask(ord[j], ord[x])) {
            j += 1;
        }

        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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 15 ms 388 KB Output is correct
17 Correct 12 ms 456 KB Output is correct
18 Correct 12 ms 388 KB Output is correct
19 Correct 13 ms 464 KB Output is correct
20 Correct 7 ms 464 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 23 ms 468 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 0 ms 208 KB Output is correct
29 Correct 0 ms 208 KB Output is correct
30 Correct 1 ms 208 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 8 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 15 ms 388 KB Output is correct
17 Correct 12 ms 456 KB Output is correct
18 Correct 12 ms 388 KB Output is correct
19 Correct 13 ms 464 KB Output is correct
20 Correct 7 ms 464 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
26 Correct 23 ms 468 KB Output is correct
27 Correct 1 ms 208 KB Output is correct
28 Correct 0 ms 208 KB Output is correct
29 Correct 0 ms 208 KB Output is correct
30 Correct 1 ms 208 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 8 ms 484 KB Output is correct
33 Correct 107 ms 1592 KB Output is correct
34 Correct 105 ms 1544 KB Output is correct
35 Correct 109 ms 1480 KB Output is correct
36 Correct 52 ms 1524 KB Output is correct
37 Correct 111 ms 1576 KB Output is correct
38 Correct 98 ms 1548 KB Output is correct
39 Correct 102 ms 1476 KB Output is correct
40 Correct 98 ms 1524 KB Output is correct
41 Correct 54 ms 1452 KB Output is correct
42 Correct 93 ms 1552 KB Output is correct
43 Correct 67 ms 1700 KB Output is correct
44 Correct 101 ms 1456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 96 ms 1524 KB Partially correct
2 Partially correct 98 ms 1588 KB Partially correct
3 Partially correct 82 ms 1492 KB Partially correct
4 Partially correct 105 ms 1504 KB Partially correct
5 Partially correct 77 ms 1512 KB Partially correct
6 Correct 64 ms 1120 KB Output is correct
7 Correct 66 ms 1176 KB Output is correct
8 Partially correct 104 ms 1520 KB Partially correct
9 Partially correct 76 ms 1476 KB Partially correct
10 Partially correct 101 ms 1520 KB Partially correct
11 Partially correct 99 ms 1480 KB Partially correct
12 Partially correct 93 ms 1492 KB Partially correct
13 Correct 101 ms 1316 KB Output is correct
14 Correct 90 ms 1360 KB Output is correct
15 Correct 48 ms 932 KB Output is correct
16 Correct 44 ms 1000 KB Output is correct
17 Correct 74 ms 1436 KB Output is correct
18 Correct 55 ms 836 KB Output is correct