UESTC OJ1221(DFS)
来源:互联网 发布:php curl 设置编码 编辑:程序博客网 时间:2024/06/04 08:05
南阳CCPC的G题,最水的之一。
挖掉那些已经死掉的白子,问能不能一步围杀白子。
数据很小随便搞。
#include <bits/stdc++.h>using namespace std;#define maxn 11#define move Movechar mp[maxn][maxn];const int move[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};bool legal (int i, int j) { if (i < 0 || j < 0 || i >= 9 || j >= 9) return 0; return 1;}bool vis[maxn][maxn];int dfs (int x, int y) { int ans = 0; vis[x][y] = 1; if (mp[x][y] == '.') return 1; for (int i = 0; i < 4; i++) { int xx = x+move[i][0]; int yy = y+move[i][1]; if (legal (xx, yy) && !vis[xx][yy] && mp[xx][yy] != 'x') { ans += dfs (xx, yy); } } return ans;}int main () { //freopen ("in", "r", stdin); ios::sync_with_stdio(false); int t, kase = 0; cin >> t; while (t--) { cout << "Case #" << ++kase << ": "; for (int i = 0; i < 9; i++) cin >> mp[i]; bool ok = 0; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { if (mp[i][j] == 'o') { memset (vis, 0, sizeof vis); if (dfs (i, j) == 1) { cout << "Can kill in one move!!!" << endl; goto out; } } } } cout << "Can not kill in one move!!!" << endl; out: ; } return 0;}
0 0
- UESTC OJ1221(DFS)
- UESTC Treasure----dfs
- UESTC--1262--Memory(dfs)
- UESTC 889 Battle for Silver (dfs)
- UESTC 1252 24点游戏 DFS
- UESTC--1252--24点游戏(dfs)
- UESTC - 1039 Fabricate equation (DFS&模拟)
- UESTC 1252 24点问题 DFS
- UESTC
- UESTC
- UESTC
- UESTC
- UESTC
- UESTC
- UESTC
- UESTC
- UESTC
- UESTC
- 洛谷1791/CODEVS1214线段覆盖
- 冒泡排序
- WM_PAINT与WM_ERASEBKGND补充
- Android读书笔记------View动画(2)
- EditText的使用方法详解
- UESTC OJ1221(DFS)
- C socket TCP/UDP client/server example codes
- 2015 长春、沈阳区域赛总结
- 解决MAC ssh本地断开后启动的服务会停止的问题
- switch跳转表分析
- 通知——Notification
- 10003---使用jQuery实现Ajax
- LeetCode:Rotate Array
- Effective Objective-C 2.0 第11条:理解objc_msgSend的作用