답안 #291197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
291197 2020-09-04T21:10:32 Z Ruba_K 동굴 (IOI13_cave) C++14
0 / 100
578 ms 500 KB
#include "cave.h"
#include<bits/stdc++.h>
using namespace std ;

void exploreCave(int N) {
    int constant[N] , arr[N] , pos[N];
    memset(constant , 0 , sizeof constant);

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


    for(int i = 0 ; i < N ; i ++){
        int ret = tryCombination(arr);
        if(ret != i){
            for(int j = 0 ; j < N ; j ++){
                if(constant[j])continue ;
                arr[j] = (arr[j] + 1 ) % 2 ;
            }
        }
        int l = 0 , r = N - 1 , md ;
        while(l < r){
            md = (l + r) / 2 ;

            int check[N];
            for(int j = 0 ; j < N ; j ++){
                if(constant[j])check[j] = arr[j];

                else
                    check[j] = (j >= l && j <= md ? arr[j] : arr[j] ^ 1);
            }
            ret = tryCombination(check);
            if(ret == i)r = md ;
            else l = md + 1 ;
        }

        constant[l] = 1 ;
        arr[l] ^= 1 ;
        pos[l] = i ;

    }


}

Compilation message

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:6:32: warning: variable 'pos' set but not used [-Wunused-but-set-variable]
    6 |     int constant[N] , arr[N] , pos[N];
      |                                ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 356 ms 500 KB answer() 함수를 반드시 호출해야 합니다.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 578 ms 384 KB answer() 함수를 반드시 호출해야 합니다.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB answer() 함수를 반드시 호출해야 합니다.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB answer() 함수를 반드시 호출해야 합니다.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 356 ms 500 KB answer() 함수를 반드시 호출해야 합니다.
2 Halted 0 ms 0 KB -