반응형
https://school.programmers.co.kr/learn/courses/30/lessons/42898
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
아오 이거 왜 물웅덩이 x y 순서 거꾸로인지 헷갈리게
이러지마제발
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int solution(int row, int col, vector<vector<int>> puddles) {
int answer = 0; // row 가로 col 세로
vector<vector<int> > board(col, vector<int>(row, 0));
board[0][0] = 1;
for (int i = 0; i < puddles.size(); i++)
board[puddles[i][1] - 1][puddles[i][0] - 1] = -1; // 0 부터 시작이라 1씩 빼줌
for (int i = 0; i < col; i++) {
for (int j = 0; j < row; j++) {
if (board[i][j] == -1)
continue ;
int sum = 0;
if (i - 1 >= 0 && board[i - 1][j] != -1)
sum += board[i - 1][j];
if (j - 1 >= 0 && board[i][j - 1] != -1)
sum += board[i][j - 1];
board[i][j] += sum % 1000000007;
}
}
return board[col - 1][row - 1];
}
반응형
'<algorithm> > 프로그래머스' 카테고리의 다른 글
프로그래머스 여행경로 c++ (0) | 2023.11.04 |
---|---|
프로그래머스 단속카메라 c++ (0) | 2023.09.24 |
프로그래머스 소수 찾기 c++ (0) | 2023.09.09 |
프로그래머스 스킬트리 c++ (0) | 2023.09.08 |
프로그래머스 PCCP모의고사 1회 3번 유전법칙 c++ (0) | 2023.09.08 |