acgo题库
  • 首页
  • 题库
  • 学习
  • 天梯
  • 备赛

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
  • 资讯
  • 竞赛
  • 讨论
  • 团队
  • 商城
登录
注册
题目详情提交记录(0)
  • 题解

    #include <bits/stdc++.h> using namespace std; int n, m, ans; int a[15][15]; bool vis[15][15]; int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1}; bool check(int x, int y) { for (int k = 0; k < 8; k++) { int nx = x + dx[k]; int ny = y + dy[k]; if (nx >= 1 && nx <= n && ny >= 1 && ny <= m && vis[nx][ny]) { return false; } } return true; } void dfs(int x, int y, int sum) { if (y > m) { // 换行 x++; y = 1; } if (x > n) { // 全部遍历完 ans = max(ans, sum); return; } } int main() { int t; cin >> t; while (t--) { cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } memset(vis, 0, sizeof(vis)); ans = 0; dfs(1, 1, 0); cout << ans << endl; } return 0; }

    userId_undefined
    未知
    模拟·模拟练习生倔强青铜冒泡宗师→排序元老
    0阅读
    0回复
    0点赞
暂无数据

提交答案之后,这里将显示提交结果~

首页