Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solved 보행자천국- 24.78ms 7.59mb #252

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Programmers/보행자천국/보행자천국_조은영.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

int MOD = 20170805;
int dp[501][501][2];

// ���� ������ ������ ��� �Լ� ���� �ʱ�ȭ �ڵ带 �� �ۼ����ּ���.
int solution(int m, int n, vector<vector<int>> city_map) {
int answer = 0;

memset(dp, 0, sizeof(dp));

dp[1][1][0] = 1;
dp[1][1][1] = 1;

for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
int num = city_map[i - 1][j - 1];
if (num == 0) {
dp[i][j][0] += (dp[i - 1][j][0] + dp[i][j - 1][1]) % MOD;
dp[i][j][1] += (dp[i - 1][j][0] + dp[i][j - 1][1]) % MOD;
}
else if (num == 1) continue;
else {
dp[i][j][0] = dp[i - 1][j][0] % MOD;
dp[i][j][1] = dp[i][j - 1][1] % MOD;
}
}
}

answer = (dp[m][n][0]) % MOD;

cout << answer << "\n";

return answer;
}