警示后人

P1219 [USACO1.5] 八皇后 Checker Challenge

```c #include <iostream> using namespace std; const int N = 110; int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1}; int st[N]; char g[N][N]; int n, m, maxx = 0; void bfs(int x, int y, int cnt) { maxx = max(maxx, cnt); for(int i = 0; i < 4; i ++ ) { int nx = x + dx[i], ny = y + dy[i]; if(nx >= 0 && nx < n && ny >= 0 && ny < m && st[g[nx][ny]] == 0) { st[g[nx][ny]] = 1; bfs(nx, ny, cnt + 1); st[g[nx][ny]] = 0; } } } int main() { cin >> n >> m; for(int i = 0; i < n; i ++ )for(int j = 0; j < m; j ++ )cin >> g[i][j]; st[g[0][0]] = 1; bfs(0, 0, 1); cout << maxx << endl; return 0; } ```
by dzkccc @ 2024-04-27 14:41:47


why? ? ? @[dzkccc](/user/1277552)
by 123uuu @ 2024-05-04 12:23:21


发错了
by dzkccc @ 2024-05-04 14:42:10


|