AcWing 1320. New Online Judge 1320: [蓝桥杯2017初赛]方格分割
原题链接
简单
作者:
史一帆
,
2021-03-28 17:26:24
,
所有人可见
,
阅读 517
DFS (充分考虑对称性)
#include <iostream>
using namespace std;
int ans;
bool vis[10][10];
const int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
void dfs(int x, int y)
{
if (x == 0 || x == 6 || y == 0 || y == 6)
{
ans ++;
return;
}
for (int i = 0; i < 4; i ++)
{
int newx = x + dx[i], newy = y + dy[i];
if (!vis[newx][newy])
{
vis[newx][newy] = true;
vis[6 - newx][6 - newy] = true;
dfs(newx, newy);
vis[newx][newy] = false;
vis[6 - newx][6 - newy] = false;
}
}
}
int main()
{
vis[3][3] = true;
dfs(3, 3);
cout << ans / 4 << endl;
return 0;
}
题解位置放错了吧😂
当时看不支持NewOnlineJudge就借着Acwing写了
6