请问各位佬,我这个E为什么只过了百分之九十?

#include <iostream>

#include<algorithm>

#include<vector>

#define ll long long

using namespace std;

int ans[1005][1005], m[1005][1005];

int tex[4][2] = { 0,1,1,0,0,-1,-1,0 }, bh = 0, res1 = 0;

int n;

bool u = false;

void dfs(int y, int x, int bm)

{

for (int i = 0; i <= 3; i++)

{

if (u) return;

int ty = y + tex[i][0], tx = x + tex[i][1];

if (ty<1 || ty>n || tx<1 || tx>n || ans[ty][tx] == 2 || m[ty][tx] == bm) continue;

if (ans[ty][tx] == 0) {

u = true;

return;

}

else if (ans[ty][tx] == 1)

{

res1++;

m[ty][tx] = bm;

dfs(ty, tx, bm);

}

}

}

int main()

{

ios::sync_with_stdio(false);

cin.tie(0), cout.tie(0);

cin >> n;

for(int i=1;i<=n;i++)

for (int j = 1; j <= n; j++)

{

char x;

cin >> x;

if (x == '.') ans[i][j] == 0;

else if (x == '*')

ans[i][j] = 1;

else ans[i][j] = 2;

}

int res = 0;

for(int i=1;i<=n;i++)

{

for (int j = 1; j <= n; j++)

{

if (ans[i][j] == 0)

{

bh++;

int res2 = 0;

for (int v = 0; v < 4; v++)

{

int ty = i + tex[v][0], tx = j + tex[v][1];

if (ty<1 || ty>n || tx<1 || tx>n) continue;

if (ans[ty][tx] == 1)

{

if (m[ty][tx] == bh) continue;

ans[i][j] = 2;

u = false;

res1 = 1;

m[ty][tx] = bh;

dfs(ty, tx, bh);

if (!u) res2=res2+res1;

ans[i][j] = 0;

}

}

res = max(res, res2);

}

}

}

cout << res;

}

全部评论
3 ... .*. **#   你输出了2
点赞 回复 分享
发布于 02-10 01:40 浙江
鹅,你可以看一下有没有判断一子吃多“块”白子的情况。
点赞 回复 分享
发布于 02-10 08:08 广东

相关推荐

后端彭于晏:你无敌了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务