제출 #318789

#제출 시각아이디문제언어결과실행 시간메모리
318789Wesley_Wang동굴 (IOI13_cave)C++14
0 / 100
26 ms484 KiB
#include "cave.h"
#include <bits/stdc++.h>

using namespace std;

int determine[5000];
int correspond[5000];

int ord[5000];

void DoSort (int left, int right)
{
    if (left == right)
    {
        correspond[left] = ord[left];
        return;
    }

    int pivot = tryCombination(determine);
    int pivot_point = 0;

    int r = right;

    for (int i = left; i <= right; i++)
    {
        int o = correspond[i];
        determine[correspond[o]] = !determine[correspond[o]];
        int t = tryCombination(determine);
        if (t != pivot)
        {
            correspond[i] = t;
            if (t > pivot)
                pivot_point = i;
        }
        else
            correspond[i] = r--;
        determine[correspond[o]] = !determine[correspond[o]];
    }
    determine[correspond[pivot_point]] = !determine[correspond[pivot_point]];
    DoSort(pivot + 1, right);
}

void exploreCave(int N) {

    for (int i = 0; i < N; i++)
        determine[i] = rand() % 2;

    for (int i = 0; i < N; i++)
        correspond[i] = i;

    DoSort(0, N);
    answer(determine, correspond);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...