답안 #423455

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
423455 2021-06-11T07:05:45 Z 반딧불(#7610) Monster Game (JOI21_monster) C++17
91 / 100
146 ms 320 KB
#include <bits/stdc++.h>
#include "monster.h"

using namespace std;

typedef long long ll;

namespace {
    int n;
    int arr[1002];
    int arr2[1002];

    void Sort(int l, int r){
        if(l>=r) return;
        int m = (l+r)>>1;
        Sort(l, m);
        Sort(m+1, r);

        for(int i=l; i<=r; i++) arr2[i] = arr[i];
        for(int i=l, j=m+1, k=l; k<=r; k++){
            if(i==m+1) arr[k] = arr2[j++];
            else if(j==r+1) arr[k] = arr2[i++];
            else if(Query(arr2[i], arr2[j]) == 0) arr[k] = arr2[i++];
            else arr[k] = arr2[j++];
        }
    }



    int comp[1002];
}

vector<int> Solve(int N){
    n = N;
    for(int i=0; i<n; i++) arr[i] = i;
    random_shuffle(arr, arr+n);
    Sort(0, n-1);

    for(int i=1; i<n; i++){
        comp[i] = Query(arr[0], arr[i]);
    }
    if(accumulate(comp+1, comp+n, 0) == 1){ /// ù ���� 0 �Ǵ� 1
        int tmp = find(comp+1, comp+n, 1) - comp;
        if(tmp == 1) {} /// ù ���� 0�̴�.
        else if(tmp != 2){
            if(Query(arr[1], arr[tmp])) {} /// ù ���� 0�̴�.
            else swap(arr[0], arr[1]); /// ù ���� 1�̹Ƿ� ��ȯ�Ѵ�.
        }
        else{
            int sum = 0;
            for(int i=3; i<n; i++){
                sum += Query(arr[1], arr[i]);
                if(sum) break;
            }
            if(sum) {}
            else swap(arr[0], arr[1]);
        }
    }
    else{
        int tmp = accumulate(comp+1, comp+n, 0);
        if(tmp == n-2){
            if(Query(arr[1], arr[n-1])) reverse(arr, arr+n);
            else reverse(arr, arr+n-1);
        }
        else{
            reverse(arr, arr+tmp+1);
        }
    }

    int tmp = 0;
    for(int i=1; i<n; i++){
        if(Query(arr[tmp], arr[i]) == 1){
            reverse(arr+tmp+1, arr+i+1);
            tmp = i;
        }
    }

//    for(int i=0; i<n; i++) printf("%d ", arr[i]);
//    puts("");

    vector<int> idx (n);
    for(int i=0; i<n; i++) idx[arr[i]] = i;
    return idx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 200 KB Output is correct
12 Correct 1 ms 200 KB Output is correct
13 Correct 1 ms 200 KB Output is correct
14 Correct 1 ms 200 KB Output is correct
15 Correct 1 ms 200 KB Output is correct
16 Correct 21 ms 200 KB Output is correct
17 Correct 19 ms 200 KB Output is correct
18 Correct 18 ms 200 KB Output is correct
19 Correct 8 ms 200 KB Output is correct
20 Correct 17 ms 200 KB Output is correct
21 Correct 1 ms 200 KB Output is correct
22 Correct 1 ms 200 KB Output is correct
23 Correct 1 ms 200 KB Output is correct
24 Correct 1 ms 200 KB Output is correct
25 Correct 1 ms 200 KB Output is correct
26 Correct 16 ms 200 KB Output is correct
27 Correct 1 ms 200 KB Output is correct
28 Correct 1 ms 200 KB Output is correct
29 Correct 1 ms 200 KB Output is correct
30 Correct 1 ms 200 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 17 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 200 KB Output is correct
12 Correct 1 ms 200 KB Output is correct
13 Correct 1 ms 200 KB Output is correct
14 Correct 1 ms 200 KB Output is correct
15 Correct 1 ms 200 KB Output is correct
16 Correct 21 ms 200 KB Output is correct
17 Correct 19 ms 200 KB Output is correct
18 Correct 18 ms 200 KB Output is correct
19 Correct 8 ms 200 KB Output is correct
20 Correct 17 ms 200 KB Output is correct
21 Correct 1 ms 200 KB Output is correct
22 Correct 1 ms 200 KB Output is correct
23 Correct 1 ms 200 KB Output is correct
24 Correct 1 ms 200 KB Output is correct
25 Correct 1 ms 200 KB Output is correct
26 Correct 16 ms 200 KB Output is correct
27 Correct 1 ms 200 KB Output is correct
28 Correct 1 ms 200 KB Output is correct
29 Correct 1 ms 200 KB Output is correct
30 Correct 1 ms 200 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 17 ms 200 KB Output is correct
33 Correct 95 ms 280 KB Output is correct
34 Correct 83 ms 300 KB Output is correct
35 Correct 111 ms 284 KB Output is correct
36 Correct 81 ms 284 KB Output is correct
37 Correct 101 ms 284 KB Output is correct
38 Correct 132 ms 280 KB Output is correct
39 Correct 88 ms 288 KB Output is correct
40 Correct 106 ms 320 KB Output is correct
41 Correct 118 ms 288 KB Output is correct
42 Correct 105 ms 288 KB Output is correct
43 Correct 101 ms 284 KB Output is correct
44 Correct 91 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 106 ms 284 KB Partially correct
2 Partially correct 145 ms 284 KB Partially correct
3 Partially correct 109 ms 288 KB Partially correct
4 Partially correct 82 ms 284 KB Partially correct
5 Partially correct 79 ms 284 KB Partially correct
6 Correct 74 ms 320 KB Output is correct
7 Correct 97 ms 284 KB Output is correct
8 Partially correct 108 ms 280 KB Partially correct
9 Partially correct 116 ms 320 KB Partially correct
10 Partially correct 146 ms 200 KB Partially correct
11 Partially correct 125 ms 288 KB Partially correct
12 Partially correct 124 ms 200 KB Partially correct
13 Correct 87 ms 284 KB Output is correct
14 Correct 109 ms 284 KB Output is correct
15 Correct 53 ms 280 KB Output is correct
16 Correct 41 ms 284 KB Output is correct
17 Correct 115 ms 280 KB Output is correct
18 Correct 61 ms 284 KB Output is correct