# Checkerboard-type dynamic planning Code[vs] 1010 River Crossing 2002 Noip National League universal Group

Source: Internet
Author: User

`/*dp[i][j]: = The number of paths from the starting point [0][0] to the position where the coordinates are [i][j]. Stroke rule: can be down, or to the right, so dp[i][j] = Dp[i-1][j] + dp[i][j-1]            (down) (right) Note: Remove the other side of the horse's control point attached: Codevs test data is somewhat weak, you can consider here to evaluate: Clear Orange (the main difference is that the dp[][] data type is set to long long) */`
`1#include <iostream>2#include <cstdlib>3#include <cstdio>4#include <cstddef>5#include <iterator>6#include <algorithm>7#include <locale>8#include <cmath>9#include <vector>Ten#include <cstring> One using namespacestd; A Const intINF =0x3f3f3f3f; - Const intMAXN = -; - Const intMAXM = -; the Const intMaxavoid =9; -  - intN, m, x, y; - BOOLARR[MAXN][MAXM]; + Long LongDP[MAXN][MAXM]; - intAvoidx[maxavoid] = {0, -1, -2, -2, -1,1,2,2,1}; + intAvoidy[maxavoid] = {0, -2, -1,1,2,2,1, -1, -2}; A  at  - voidSolve () - { -     if(!arr[0][0]) -     { -         //DP Initialization indp[0][0] =1; -     } to      for(inti =0; I <= N; ++i) +     { -          for(intj =0; J <= M; ++j) the         { *             if(!Arr[i][j]) \$             {Panax Notoginseng                 if((I-1) >=0) Dp[i][j] + = dp[i-1][j]; -                 if(J-1) >=0) Dp[i][j] + = dp[i][j-1]; the             }  +         } A     } thecout << Dp[n][m] <<Endl; + } -  \$ intMain () \$ { -  -CIN >> n >> m >> x >>y; thememset (arr,0,sizeof(arr)); -Memset (DP,0,sizeof(DP));Wuyi     //Remove the other horse's control points the      for(inti =0; i < maxavoid; ++i) -     { Wu         inttx = x +Avoidx[i]; -         intTy = y +Avoidy[i]; About         if(TX >=0) && (TX <= N) && (Ty >=0) && (Ty <=m)) \$         { -Arr[tx][ty] =true; -         } -     } A Solve (); +  the      - #ifdef HOME \$Cerr <<"Time Elapsed:"<< clock ()/Clocks_per_sec <<"Ms"<<Endl; the #endif the     return 0; the}`

Checkerboard-type dynamic planning Code[vs] 1010 River Crossing 2002 Noip National League universal Group

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.