it is to be noted that dp[0][0] To initialize to 1.

int totalPath(vector<vector<bool> > &blocked) {
int m = blocked.size();
if (m == 0) return 0;
int n = blocked[0].size();
if (n == 0) return 0;
vector<vector<int> > dp(m);
for (int i = 0; i < m; i++) {
dp[i].resize(n, 0);
}
if (!blocked[0][0]) dp[0][0] = 1;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (blocked[i][j]) {
dp[i][j] == 0;
} else {
if (i-1 >= 0) dp[i][j] += dp[i-1][j];
if (j-1 >= 0) dp[i][j] += dp[i][j-1];
}
}
}
return dp[m-1][n-1];
}

[itint5] More related articles about chessboard walk

  1. [itint5] Right angle route traversal chessboard

    http://www.itint5.com/oj/#22 The problem started with violence DFS To do it , Sure enough 25 The scale of the project is gone . vector<bool> visited(50, false); ve ...

  2. TYVJ1035 Chessboard coverage

    Time : 1000ms / Space : 131072KiB / Java Class name : Main describe Give me a picture n*n(n<=100) The chess board of , Some of them have been deleted , Ask how much you can use 1*2 The dominoes are covered ...

  3. POJ 1321 Chessboard problem (dfs)

    Portal Chessboard problem Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 38297   Accepted: 18761 Descri ...

  4. Design an automatic generation chessboard grid JS Applet

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  5. BZOJ1057[ZJOI2007] Chessboard making [ Monotonic stack ]

    Title Description Chess is one of the oldest games in the world , And Chinese go . Chess and Japanese Jiangqi share a great reputation . It is said that chess originated from the idea of the book of changes , The chessboard is a 8*8 The size of the black and white square , Corresponding to the eight hundred and sixty-four hexagrams , Black and white correspond to Yin and Yang . And ours ...

  6. 【BZOJ-3039&amp;1057】 Jade toad Palace &amp; Chessboard making Suspension method

    3039: Jade toad Palace Time Limit: 2 Sec  Memory Limit: 128 MBSubmit: 753  Solved: 444[Submit][Status][Discuss] D ...

  7. 【ZJOI2007】 Chessboard making BZOJ1057

    Description countries Chess is one of the oldest games in the world , And Chinese go . Chess and Japanese Jiangqi share a great reputation . It is said that chess originated from the idea of the book of changes , The chessboard is a 8*8 The size of the black and white square front , Corresponding to the eight hundred and sixty-four hexagrams , Black and white ...

  8. Unity Hand rolling 2048 Little games —— Automatic generation 4*4 The board

    1. New folder , life prefabs, Just made Chessman Drag into the file , Make a prefab 2. Delete panel Under the Chessman 3. stay panel Next , Create a new empty object , Name it Chessboard, Size settings ...

  9. C# How to draw a go board

    C# Drawing is not so beautiful , But for simple graphics , We don't pay attention to the aesthetic quality of the picture , use C# It's very convenient . The background color . Draw chart line colors . The size of vertical and horizontal columns can be adjusted according to personal preference . Does not provide AI Code , I designed it myself AI It's not perfect , I won't show it to you , count ...

Random recommendation

  1. nsq

    Official website :http://nsq.io (1) describe All are message broker,rabbitmq Time-tested ,nsq It's a rising star .rabbitmq yes erlang To write ,nsq yes golang. install :http ...

  2. [Effective JavaScript note ] The first 32 strip : Never modify __proto__ attribute

    __proto__ The attributes are special , It provides Object.getPrototypeOf Additional capabilities that methods don't have , The ability to modify object prototype Links . Avoid modifying __proto__ The most obvious reason for attributes is portability . Not at all ...

  3. Qt And QSS( Black is cool )

    sketch Qt There are various parts in the assistant QSS Explain in detail , It's rich in resources , Please refer to :Qt Style Sheets Examples. Black is cool - A beautiful one QSS style . I've shared a lot about Qt The style effect of , A few ...

  4. Android Studio Compile not pass , Report errors “ Can't find org.apache.http

    If you use it  target sdk yes 23 Please be there. build.gradle Join in android{ useLibrary ‘org.apache.http.legacy‘ }

  5. Ubuntu Mysql Open access to the Internet

    Ubuntu Mysql Open access to the Internet   1. edit my.cnf file : sudo vi /etc/mysql/my.cnf   2. Comment out the binding address line or modify it to specify IP #bind-addre ...

  6. ServletRequest Some knowledge points of

    Browser requests to the server ( When the browser sends data to the server , Where the data is stored )  Request mode :GET and POST * GET: Data sent , Append to the requested URL above * POST: The data sent is in HTTP Request body   The number of browsers sent ...

  7. iOS Only vertical screen is allowed by default , Vertical and horizontal conversion in a separate interface , Screen rotation

    Contains only . On the horizontal and vertical screen code #import "InspectionReportViewController.h" #define SCREEN_WIDTH ([UIScreen m ...

  8. Python3 in Climb the web \uxxx problem

    This morning, I will climb my own blog home page to practice . Encoding problems encountered while writing , For a long time , Make a note of import urllib.request import time str1 = urllib.r ...

  9. python Study : Change string case

    Change string case function :title() The initial of a string is uppercase ,upper() String all uppercase ,lower() String all lowercase . The code for : name = "ada lovelace"prin ...

  10. linux in &amp;&amp; And || The principle of judgment

    [root@linuxprobe ~]# [ $USER = root ] && echo "root" || echo "user"root[ ...