답안 #545738

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545738 2022-04-05T10:15:39 Z alextodoran Monster Game (JOI21_monster) C++17
0 / 100
136 ms 4244 KB
#include <bits/stdc++.h>

using namespace std;

bool Query (int a, int b);

vector <vector <int>> cmp;
bool ask (int a, int b) {
    if (a > b) {
        swap(a, b);
        if (cmp[a][b] == -1) {
            cmp[a][b] = Query(a, b);
        }
        return !cmp[a][b];
    } else {
        if (cmp[a][b] == -1) {
            cmp[a][b] = Query(a, b);
        }
        return cmp[a][b];
    }
}

vector <int> Solve (int N) {
    cmp = vector <vector <int>> (N, vector <int> (N, -1));
    vector <int> order (N);
    iota(order.begin(), order.end(), 0);
    sort(order.begin(), order.end(), [&] (const int &i, const int &j) {
        return ask(j, i);
    });
    int K = min(N, 10);
    vector <int> cnt (K, 0);
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            if (i != j) {
                cnt[i] += ask(order[i], order[j]);
            }
        }
    }
    vector <int> aux (K);
    iota(aux.begin(), aux.end(), 0);
    sort(aux.begin(), aux.end(), [&] (const int &i, const int &j) {
        return cnt[i] < cnt[j];
    });
    int currMin = (ask(order[aux[0]], order[aux[1]]) == true ? aux[0] : aux[1]);
    reverse(order.begin(), order.begin() + currMin + 1);
    while (currMin + 1 < N) {
        int nextMin = currMin + 1;
        while (ask(order[currMin], order[nextMin]) == false) {
            nextMin++;
        }
        reverse(order.begin() + currMin + 1, order.begin() + nextMin + 1);
        currMin = nextMin;
    }
    vector <int> ret (N);
    for (int i = 0; i < N; i++) {
        ret[order[i]] = i;
    }
    return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 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 1 ms 208 KB Output is correct
10 Correct 1 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 13 ms 336 KB Output is correct
17 Correct 11 ms 336 KB Output is correct
18 Correct 17 ms 336 KB Output is correct
19 Correct 10 ms 464 KB Output is correct
20 Correct 11 ms 336 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 2 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 18 ms 336 KB Output is correct
27 Correct 2 ms 208 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 1 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 Runtime error 10 ms 700 KB Execution killed with signal 11
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 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 1 ms 208 KB Output is correct
10 Correct 1 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 13 ms 336 KB Output is correct
17 Correct 11 ms 336 KB Output is correct
18 Correct 17 ms 336 KB Output is correct
19 Correct 10 ms 464 KB Output is correct
20 Correct 11 ms 336 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 2 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 18 ms 336 KB Output is correct
27 Correct 2 ms 208 KB Output is correct
28 Correct 1 ms 208 KB Output is correct
29 Correct 1 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 Runtime error 10 ms 700 KB Execution killed with signal 11
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 66 ms 4176 KB Partially correct
2 Partially correct 75 ms 4240 KB Partially correct
3 Partially correct 108 ms 4240 KB Partially correct
4 Partially correct 89 ms 4244 KB Partially correct
5 Partially correct 78 ms 4176 KB Partially correct
6 Partially correct 91 ms 4176 KB Partially correct
7 Partially correct 61 ms 4240 KB Partially correct
8 Partially correct 67 ms 4176 KB Partially correct
9 Partially correct 51 ms 4232 KB Partially correct
10 Partially correct 86 ms 4236 KB Partially correct
11 Partially correct 116 ms 4232 KB Partially correct
12 Partially correct 89 ms 4176 KB Partially correct
13 Incorrect 136 ms 4232 KB Wrong Answer [6]
14 Halted 0 ms 0 KB -