Baekjoon #14712

Baekjoon #14712

3개의 풀이 · C++, Java, Python

문제 원문 보기 ↗

SOLUTION INFO

C++ · main.cpp

main.cpp
#include<bits/stdc++.h>

using namespace std;

int N, M, Map[33][33]; // 1-index
int answer = 0;

bool check(int y, int x) {
    return Map[y-1][x] && Map[y][x-1] && Map[y-1][x-1];
}

void go(int usedCnt) {
    if(usedCnt == N * M) {
        answer ++;
        return ;
    }

    int y = usedCnt / M + 1;
    int x = usedCnt % M + 1;

    go(usedCnt + 1);
    if(!check(y, x)) {
        Map[y][x] = 1;
        go(usedCnt + 1);
        Map[y][x] = 0;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N >> M;
    go(0);
    cout << answer;

    return 0;
}

SOLUTION DESCRIPTION

풀이 설명

등록된 풀이 설명이 없습니다.