제출 #1291057

#제출 시각아이디문제언어결과실행 시간메모리
1291057lechaaCave (IOI13_cave)C++20
0 / 100
87 ms512 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;

//

void exploreCave(int n) {
    int d[n];
    int cur[n];
    for(int i = 0; i < n; i++){
        d[i] = -1;
        cur[i] = -1;
    }
    for(int i = 0; i < n; i++){
        int j = tryCombination(cur);
        if(j == i){
            int low = 0;
            int top = n-i-1;
            int ns = 0;
            while(low <= top){
                int mid = (low + top)/2;
                int ncur[n];
                int co = 0;
                int l = 0;
                for(int y = 0; y < n && co <= mid; y++){
                    if(d[y] != -1){
                        ncur[y] = cur[y];
                    }else{
                        l = y;
                        co++;
                        ncur[y] = 1;
                    }
                }
                if(tryCombination(ncur) > i){
                    ns = l;
                    top = mid-1;
                }else{
                    low = mid+1;
                }
            }
            cur[ns] = 1;
            d[ns] = i;
        }else{
            int low = 0;
            int top = n-i-1;
            int ns = 0;
            while(low <= top){
                int mid = (low + top)/2;
                int ncur[n];
                int co = 0;
                int l = 0;
                for(int y = 0; y < n && co <= mid; y++){
                    if(d[y] != -1){
                        ncur[y] = cur[y];
                    }else{
                        l = y;
                        co++;
                        ncur[y] = 1;
                    }
                }
                if(tryCombination(ncur) <= i){
                    ns = l;
                    top = mid-1;
                }else{
                    low = mid+1;
                }
            }
            d[ns] = i;
        }
    }
    // for(int i = 0; i < n; i++){
    //     cout << cur[i] << " ";
    // }cout << "\n";
    // for(int i = 0; i < n; i++){
    //     cout << d[i] << " ";
    // }cout << "\n";
    answer(cur, d);
}
#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...