개발자 톡

연습문제 톡 [HSAT 2회 정기 코딩 인증평가 기출] Garage game

Garage Game 반례를 찾고싶습니다 고수님들 도와주세요

등록일
2021-10-20 01:17:31
조회수
800
작성자
girlzzz03

아래 코드로 fail 7개 뜨네요 ㅠㅠ 고수님들의 도움 기다립니다,,



#include
#include
#include
#include
#include

using namespace std;

int N;
int new_block[45][15] = {0, };
int visit[45][15] = {0, };
int answer = 0;
int real_answer = 0;
stack answer_stack;

bool compare(pair  p1, pair  p2){
    if (p1.second == p2.second) {
        return p1.first < p2.first;
    }    
    return p1.second < p2.second;
}

int dfs(int x, int y, int ref_val, vector > &block_vectors)
{
    if(x<2*N || x>=3*N || y<=-1 || y>=N) return false;
    
    if((!visit[x][y]) && (new_block[x][y] == ref_val))
    {
        visit[x][y] = true;
        block_vectors.push_back({x, y});
        dfs(x-1, y, ref_val, block_vectors);
        dfs(x+1, y, ref_val, block_vectors);
        dfs(x, y-1, ref_val, block_vectors);
        dfs(x, y+1, ref_val, block_vectors);

        return true;
    }
    return false;
}

int score = 0;
int get_blocks(int ref_val, vector > &block_vectors)
{
    int elem_cnt = 0;
    int rect_size = 0;
    int block_answer = 0;
    int max_x = 0;
    int max_y = 0;
    int min_x = 0;
    int min_y = 0;
    int block_size = 0;
    

    for(int i=2*N; i<3*N; i++){
        for(int j=0; j > find_block_vectors;
            dfs(i, j, ref_val, find_block_vectors);
            if(block_size < find_block_vectors.size()){
                block_vectors = find_block_vectors;
                block_size = find_block_vectors.size();
            }
        }
    }
   

    elem_cnt = block_vectors.size();

    if(elem_cnt == 0) return false;

    sort(block_vectors.begin(), block_vectors.end(), compare);

    max_x = block_vectors[0].first;
    max_y = block_vectors[0].second;
    min_x = block_vectors[0].first;
    min_y = block_vectors[0].second;
    
    for(int i=1; i > &block_vectors, int prev_temp[][15])
{
    int y;
    int y_cnt;
    vector y_points;

	for(int i=0; i color_v;
    static int call_cnt = 0;

    call_cnt ++;
    
    for(int i=2*N; i<3*N; i++){
        for(int j=0; j > block_vectors_arr[color_v.size()];

    for(int i=0; i> N;
    memset(visit, 0, sizeof(int)*45*15);
    
    for(int i=0; i<3*N; i++){
        for(int j=0; j> new_block[i][j];
        }
    }

    solution(new_block);

    cout<


#[hsat_2회_정기_코딩_인증평가_기출]_garage_game
#c++

이 카테고리의 톡 더보기