网站设计师 要求,wordpress 主题语言包,网站运营建设的目标,网站建设前端后端题目#xff1a;http://www.51nod.com/onlineJudge/questionCode.html#!problemId1522 很好的思想。考虑从小到大一对一对填数#xff0c;这样也能对它的大小限制做一些操作了。 因为从小到大#xff0c;所以只能全填在左边、全填在右边、两边各填一个。记录左边填到了哪个位…题目http://www.51nod.com/onlineJudge/questionCode.html#!problemId1522 很好的思想。考虑从小到大一对一对填数这样也能对它的大小限制做一些操作了。 因为从小到大所以只能全填在左边、全填在右边、两边各填一个。记录左边填到了哪个位置就可知右边填到了哪个位置。转移之前判断一下这样填是否合法即可。 新的不合法的状态只会和现在填的两个位置有关。 注意输入格式符号前后有空格 #includeiostream
#includecstdio
#includecstring
#includealgorithm
#define ll long long
using namespace std;
const int N40,M105;
int n,m,x[M],y[M],sgn[M],tx,ty;
ll dp[N][N1],ans;
char ch[20];
bool check(int p0,int p1,int r,int fx)
{//printf(p0%d p1%d r%d fx%d\n,p0,p1,r,fx);for(int i1;im;i)if(sgn[i]0( ( (x[i]p0||x[i]p1)y[i]!p0y[i]!p1)||( (y[i]p0||y[i]p1)x[i]!p0x[i]!p1) ) )return 0;//以前都合法不合法仅出现在p0、p1位置上if(!fx){for(int i1;im;i){//printf(sgn[%d]%d\n,i,sgn[i]);if(sgn[i]1||sgn[i]2){txx[i];tyy[i];if(sgn[i]2)swap(tx,ty);//printf(tx%d ty%d p0%d p1%d r%d\n,tx,ty,p0,p1,r);if((typ0||typ1)txp0txr) return 0;}if(sgn[i]3||sgn[i]4){txx[i];tyy[i];if(sgn[i]4)swap(tx,ty);if((typ0||typ1)txp1txr) return 0;}}}if(fx1){for(int i1;im;i){if(sgn[i]1||sgn[i]2){txx[i];tyy[i];if(sgn[i]2)swap(tx,ty);if((typ0||typ1)txp1txr) return 0;}if(sgn[i]3||sgn[i]4){txx[i];tyy[i];if(sgn[i]4)swap(tx,ty);if((typ0||typ1)txp0txr) return 0;}}}if(fx2){for(int i1;im;i){if(sgn[i]1||sgn[i]2){txx[i];tyy[i];if(sgn[i]2)swap(tx,ty);if((typ0||typ1)txp0txp1) return 0;}if(sgn[i]3||sgn[i]4){txx[i];tyy[i];if(sgn[i]4)swap(tx,ty);if((typ0||typ1)txp0txp1) return 0;}}}return 1;
}
int main()
{scanf(%d%d,n,m);ch[0]getchar();while(ch[0]!\n)ch[0]getchar();for(int i1,len0,j;im;i,len0){ch[len]getchar();while(ch[len]!\n)ch[len]getchar();for(j1;jlen;j){if(ch[j]0ch[j]9)x[i](x[i]3)(x[i]1)ch[j]-0;else break;}while(ch[j] )j;//printf(j%d chj(%c)\n,j,ch[j]);if(ch[j]) sgn[i]0,j;else if(ch[j]ch[j1])sgn[i]3,j2;else if(ch[j]ch[j1])sgn[i]4,j2;else if(ch[j])sgn[i]1,j;else if(ch[j])sgn[i]2,j;while(ch[j] )j;//printf(j%d chj(%c)\n,j,ch[j]);for(;jlen;j)y[i](y[i]3)(y[i]1)ch[j]-0;//printf(x%d sgn%d y%d\n,x[i],sgn[i],y[i]);}dp[0][0]1;for(int i0,lm;in;i){lm(i1);for(int j0,r;jlm;j){//if(dp[i][j])printf(dp[%d][%d]%lld\n,i,j,dp[i][j]);r(n1)-(lm-j)1;if(check(j1,j2,r,0))dp[i1][j2]dp[i][j];//printf(dp[%d][%d]%lld(%d,%d)\n,i1,j2,dp[i1][j2],i,j);if(check(r-2,r-1,j,1))dp[i1][j]dp[i][j];//printf(dp[%d][%d]%lld(%d,%d)\n,i1,j,dp[i1][j],i,j);if(check(j1,r-1,0,2))dp[i1][j1]dp[i][j];//printf(dp[%d][%d]%lld(%d,%d)\n,i1,j1,dp[i1][j1],i,j);}}int lm(n1);for(int j0;jlm;j) ansdp[n][j];printf(%lld\n,ans/3);return 0;
} 转载于:https://www.cnblogs.com/Narh/p/9672719.html