답안 #891324

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891324 2023-12-22T18:54:19 Z lolicon Monster Game (JOI21_monster) C++17
10 / 100
108 ms 4432 KB
#include <bits/stdc++.h>
#include "monster.h"
using namespace std;

static vector<vector<int>> table;
static int n;

bool query(int a, int b) {
    if(table[a][b] != -1) return table[a][b];
    bool res = Query(a, b);
    table[a][b] = res ? 1 : 0;
    table[b][a] = res ? 0 : 1;
    return res;
}

bool test(int a, int b) {
    bool res = query(a, b);    
    int cnta = 0, cntb = 0;
    for(int i = 0; i < n; ++i) {
        if(i != a && query(a, i)) cnta++;
        if(i != b && query(b, i)) cntb++;
    }
    if(cnta == cntb) 
        return !res;
    if(!res && cnta == cntb+1)
        return !res;
    if(res && cnta+1 == cntb)
        return !res;
    return res;
    // static int arr[] = {3, 1, 4, 2, 0};
    // return arr[a] > arr[b];
}

void merge_sort(int l, int r, vector<int> &arr, vector<int> &buf) {
    if(r - l <= 1) return;
    int mid = (l + r) >> 1;
    merge_sort(l, mid, arr, buf);
    merge_sort(mid, r, arr, buf);
    int i, j, idx = l;
    for(i = l, j = mid; i < mid; ++i) {
        while(j < r && test(arr[i], arr[j])) {
            buf[idx++] = arr[j++];
        }
        buf[idx++] = arr[i];
    }
    while(j < r) buf[idx++] = arr[j++];
    for(idx = l; idx < r; ++idx)
        arr[idx] = buf[idx];
}

vector<int> Solve(int N) {
    vector<int> arr(N), buf(N);
    table.resize(N); n = N;
    for(int i = 0; i < N; ++i) 
        table[i].assign(N, -1);
    for(int i = 0; i < N; ++i) 
        arr[i] = i;
    merge_sort(0, N, arr, buf);
    vector<int> ret(N);
    for(int i = 0; i < N; ++i)  
        ret[arr[i]] = i;
    return ret;
}


#ifdef local

int main() {
    auto ans = Solve(5);
    for(int i = 0; i < 5; ++i) {
        printf("%d%c", ans[i], " \n"[i == 4]);
    }
    return 0;
}

#endif
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 412 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 78 ms 344 KB Output is correct
17 Correct 83 ms 344 KB Output is correct
18 Correct 87 ms 596 KB Output is correct
19 Correct 80 ms 576 KB Output is correct
20 Correct 83 ms 576 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 79 ms 600 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 83 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 412 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 78 ms 344 KB Output is correct
17 Correct 83 ms 344 KB Output is correct
18 Correct 87 ms 596 KB Output is correct
19 Correct 80 ms 576 KB Output is correct
20 Correct 83 ms 576 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 79 ms 600 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 83 ms 596 KB Output is correct
33 Incorrect 93 ms 4336 KB Wrong Answer [6]
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 108 ms 4432 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -