Question about a trouble I encountered when coding in c ++?
Difference between en5 and en6, changed 164 character(s)
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/tasks/dp_h: 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?↵

**I think there are a few caveats when compared to the '.' and some other special characters, if my thinking is correct, someone can explain it to me.**↵

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!

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en6 English wonderful_trip 2021-05-09 11:32:57 164
en5 English wonderful_trip 2021-05-09 07:11:13 19 Tiny change: 'ntests/dp/submissions/me : The prob' -> 'ntests/dp/tasks/dp_h: The prob'
en4 English wonderful_trip 2021-05-09 07:00:41 2
en3 English wonderful_trip 2021-05-09 06:59:59 5
en2 English wonderful_trip 2021-05-09 06:56:00 514
en1 English wonderful_trip 2021-05-09 06:54:13 2463 Initial revision (published)