- 棋盘问题
啊啊
- 2025-2-27 14:29:14 @
救命啊啊啊啊啊啊啊啊啊啊啊啊啊 30 Wrong Answer @
#include <bits/stdc++.h>
using namespace std;
const int N = 8 + 10;
int n, m;
unsigned long long ans;
bool a[N][N];
char c;
void dfs(int x, int y)
{
if (m == 0)
{
ans++;
return ;
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
if (a[i][j] and i != x and j != y)
{
a[i][j] = false;
m--;
dfs(i, j);
a[i][j] = true;
m++;
}
}
int main()
{
while(cin >> n >> m)
{
if (n == -1 and m == -1)
break;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
{
cin >> c;
if (c == '#')
a[i][j] = true;
else
a[i][j] = false;
}
dfs(0, 0);
cout << ans << endl;
ans = 0;
}
return 0;
}
1 comments
-
h_h LV 5 MOD @ 2025-2-27 23:36:44
你是不是又多组测试用例没有还原环境啊?
- 1
Information
- ID
- 703
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- # Submissions
- 92
- Accepted
- 21
- Uploaded By