51nod 1316 回文矩阵 (枚举+ 判断)

链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1316

思路: 因为n 和m 并不会很大,所以就直接枚举>=r && >=c 的所有情况,然后将这些情况的结果算出来就可以。

枚举每个点对应的四个点是否被选中就可以。

这里有几种情况51nod 1316 回文矩阵 (枚举+ 判断)_第1张图片

 

代码:

#include

using namespace std;
const int inf =0x3f3f3f;
const int N =10;
int a[N][N];
int rr,cc;
int n,m;
int yi[25];
int vis[10][10];
int hang[10];
int lie[10];
int ans;
char s[10];

void init_yi()
{
    yi[0]=1;
    for(int i=1; i<=21; i++)
        yi[i]=yi[i-1]*2;
}

int jud(int cnt,int c0,int c1)
{
    if(cnt==0) return 0;
    if(cnt==1)
        return 0;
    if(cnt==2)
    {
        if(c0==0||c1==0)
            return 0;
        return 1;
    }
    if(cnt==3)
    {
        if(c0==3||c1==3)
            return 0;
        return 1;
    }
    if(cnt==4)
    {
        if(c0==4||c1==4)
            return 0;
        if(c0==1||c1==1)
            return 1;
        return 2;
    }
}

void solve()
{
    int x1,x2,x3,x4;
    int y1,y2,y3,y4;
    int up1=yi[n];
    int up2=yi[m];
    for(int s=0; s

 

 

 

你可能感兴趣的:(思维,思维,枚举)