I just made a mistake while participating in a coding contest in Vietnam and I came across a simple dp problem, the problem was:↵
https://lqdoj.edu.vn/problem/dutpc2a : test of the contest organizers that I participated in, ↵
https://atcoder.jp/contests/dp/submissions/me : The problem I encountered is the same as the one on atcoder↵
↵
But I accepted this problem on atcoder but when I submitted the test from the contest organizer that I joined, I was wrong.↵
And the problem I have is when I compare with the character '.' I got wrong but compare with '#' then accepted.↵
Can someone explain to me why when I compare the character '.' wrong?↵
↵
this my code wrong:↵
↵
char v[nax][nax];↵
int dp[nax][nax];↵
int32_t main()↵
{↵
FASTIO↵
↵
int n, m;↵
↵
cin >> n >> m;↵
↵
for (int i = 1; i <= n; ++i) {↵
for (int j = 1; j <= m; ++j) {↵
cin >> v[i][j];↵
}↵
}↵
for (int i = 1; i <= n; ++i) {↵
for (int j = 1; j <= m; ++j) {↵
if (i == 1 && j == 1)↵
{↵
dp[i][j]=1;↵
}↵
else↵
if (v[i][j] == '.')↵
{↵
dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;↵
}↵
}↵
}↵
cout << dp[n][m];↵
return 0;↵
}↵
↵
and my code accepted:↵
↵
char v[nax][nax];↵
int dp[nax][nax];↵
int32_t main()↵
{↵
FASTIO↵
↵
int n, m;↵
↵
cin >> n >> m;↵
↵
for (int i = 1; i <= n; ++i) {↵
for (int j = 1; j <= m; ++j) {↵
cin >> v[i][j];↵
}↵
}↵
for (int i = 1; i <= n; ++i) {↵
for (int j = 1; j <= m; ++j) {↵
if (i == 1 && j == 1)↵
{↵
dp[i][j]=1;↵
}↵
else↵
{↵
if (v[i][j] != '#')↵
{↵
dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;↵
}↵
}↵
}↵
}↵
cout << dp[n][m];↵
return 0;↵
}↵
↵
Thanks for the help and sorry for my english!
https://lqdoj.edu.vn/problem/dutpc2a : test of the contest organizers that I participated in, ↵
https://atcoder.jp/contests/dp/submissions/me : The problem I encountered is the same as the one on atcoder↵
↵
But I accepted this problem on atcoder but when I submitted the test from the contest organizer that I joined, I was wrong.↵
And the problem I have is when I compare with the character '.' I got wrong but compare with '#' then accepted.↵
Can someone explain to me why when I compare the character '.' wrong?↵
↵
this my code wrong:↵
↵
char v[nax][nax];↵
int dp[nax][nax];↵
int32_t main()↵
{↵
FASTIO↵
↵
int n, m;↵
↵
cin >> n >> m;↵
↵
for (int i = 1; i <= n; ++i) {↵
for (int j = 1; j <= m; ++j) {↵
cin >> v[i][j];↵
}↵
}↵
for (int i = 1; i <= n; ++i) {↵
for (int j = 1; j <= m; ++j) {↵
if (i == 1 && j == 1)↵
{↵
dp[i][j]=1;↵
}↵
else↵
if (v[i][j] == '.')↵
{↵
dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;↵
}↵
}↵
}↵
cout << dp[n][m];↵
return 0;↵
}↵
↵
and my code accepted:↵
↵
char v[nax][nax];↵
int dp[nax][nax];↵
int32_t main()↵
{↵
FASTIO↵
↵
int n, m;↵
↵
cin >> n >> m;↵
↵
for (int i = 1; i <= n; ++i) {↵
for (int j = 1; j <= m; ++j) {↵
cin >> v[i][j];↵
}↵
}↵
for (int i = 1; i <= n; ++i) {↵
for (int j = 1; j <= m; ++j) {↵
if (i == 1 && j == 1)↵
{↵
dp[i][j]=1;↵
}↵
else↵
{↵
if (v[i][j] != '#')↵
{↵
dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;↵
}↵
}↵
}↵
}↵
cout << dp[n][m];↵
return 0;↵
}↵
↵
Thanks for the help and sorry for my english!