本文共 2198 字,大约阅读时间需要 7 分钟。
题目链接:
题意:给出一个n*m的含有障碍的格子,从左下角开始走到右下角每个格子只能走一次。有多少种?
思路:改造格子。
#include #include #include #include #include #include #include #include #include #include #include #define max(x,y) ((x)>(y)?(x):(y))#define min(x,y) ((x)<(y)?(x):(y))#define abs(x) ((x)>=0?(x):-(x))#define i64 long long#define u32 unsigned int#define u64 unsigned long long#define clr(x,y) memset(x,y,sizeof(x))#define CLR(x) x.clear()#define ph(x) push(x)#define pb(x) push_back(x)#define Len(x) x.length()#define SZ(x) x.size()#define PI acos(-1.0)#define sqr(x) ((x)*(x))#define FOR0(i,x) for(i=0;i =0;i--)#define FORL1(i,a) for(i=a;i>=1;i--)#define FORL(i,a,b)for(i=a;i>=b;i--)#define rush() int C; for(scanf("%d",&C);C--;)#define Rush(n) while(scanf("%d",&n)!=-1)using namespace std;void RD(int &x){scanf("%d",&x);}void RD(i64 &x){scanf("%lld",&x);}void RD(u32 &x){scanf("%u",&x);}void RD(double &x){scanf("%lf",&x);}void RD(int &x,int &y){scanf("%d%d",&x,&y);}void RD(u32 &x,u32 &y){scanf("%u%u",&x,&y);}void RD(double &x,double &y){scanf("%lf%lf",&x,&y);}void RD(int &x,int &y,int &z){scanf("%d%d%d",&x,&y,&z);}void RD(u32 &x,u32 &y,u32 &z){scanf("%u%u%u",&x,&y,&z);}void RD(double &x,double &y,double &z){scanf("%lf%lf%lf",&x,&y,&z);}void RD(char &x){x=getchar();}void RD(char *s){scanf("%s",s);}void RD(string &s){cin>>s;}void PR(int x) {printf("%d\n",x);}void PR(i64 x) {printf("%lld\n",x);}void PR(u32 x) {printf("%u\n",x);}void PR(double x) {printf("%.4lf\n",x);}void PR(char x) {printf("%c\n",x);}void PR(char *x) {printf("%s\n",x);}void PR(string x) {cout< < >=3;}i64 encode(int code[],int m){ i64 ans=0; int hash[15],i,cnt=1; clr(hash,-1); hash[0]=0; FOR0(i,m+1) { if(hash[code[i]]==-1) hash[code[i]]=cnt++; code[i]=hash[code[i]]; ans=(ans<<3)|code[i]; } return ans;}void update1(int i,int j){ int x,y,k,t,q=j==m?m-1:m; i64 c; FOR0(k,dp[pre].e) { decode(code,m,dp[pre].state[k]); c=dp[pre].cnt[k]; x=code[j-1]; y=code[j]; if(x&&x==y) { if(i==sx&&j==sy) ans+=c; } else if(x&&y&&x!=y) { code[j-1]=code[j]=0; FOR0(t,m+1) if(code[t]==y) code[t]=x; dp[cur].push(encode(code,q),c); } else if(x||y) { if(i
转载地址:http://pcbxx.baihongyu.com/