Tic-Tac-Toe-(暴力模拟)
https://ac.nowcoder.com/acm/contest/847/B
#include<algorithm>
#include<cstring>
#include<iostream>
#include<math.h>
#include<string>
#include<stdio.h>
#include<map>
#include<queue>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std; char a[][];
int t; bool check()
{
int num1=,num2=;///白子数,空位数
for(int i=;i<;i++)///横的
{
num1=;num2=;
for(int j=;j<;j++)
{
if( a[i][j]=='W' )
num1++;
else if( a[i][j]=='#' )
num2++;
else
break;
}
if(num1== && num2==)
return true;
} for(int j=;j<;j++)///竖的
{
num1=num2=;
for(int i=;i<;i++)
{
if( a[i][j]=='W' )
num1++;
else if( a[i][j]=='#' )
num2++;
else
break;
}
if(num1== && num2==)
return true;
}
num1=num2=;
for(int i=;i<;i++)///左上到左下
{
if( a[i][i]=='W' )
num1++;
else if( a[i][i]=='#' )
num2++;
else
break;
}
if(num1== && num2==)
return true;
num1=num2=;
for(int i=;i<;i++)///左下到右上
{
if(i==)
{
if( a[][]=='W' )
num1++;
else if( a[][]=='#' )
num2++;
else if( a[][]=='B')
break;
}
if(i==)
{
if( a[][]=='W' )
num1++;
else if( a[][]=='#' )
num2++;
else if( a[][]=='B')
break;
}
if(i==)
{
if( a[][]=='W' )
num1++;
else if( a[][]=='#' )
num2++;
else if( a[][]=='B')
break;
}
}
if(num1== && num2==)
return true;
return false;
} int main()
{
scanf("%d",&t);
while(t--)
{
int flag;
flag=;
for(int i=;i<;i++)
scanf("%s",a[i]);
if(check())///正常情况下一步能赢
{
for(int i=;i<&&flag==;i++)
{
for(int j=;j<&&flag==;j++)
{
if( a[i][j]=='W' )
{
a[i][j]='#';
if(!check())
flag=;///存在某种情况被拿了之后不能赢
a[i][j]='W';
}
}
}
if(flag==)
printf("Alice\n");
else
printf("Emmm\n");
}
else
{
printf("Bob\n");
}
}
return ;
}
Tic-Tac-Toe-(暴力模拟)的更多相关文章
- 2019 GDUT Rating Contest III : Problem C. Team Tic Tac Toe
题面: C. Team Tic Tac Toe Input file: standard input Output file: standard output Time limit: 1 second M ...
- Principle of Computing (Python)学习笔记(7) DFS Search + Tic Tac Toe use MiniMax Stratedy
1. Trees Tree is a recursive structure. 1.1 math nodes https://class.coursera.org/principlescomputin ...
- POJ 2361 Tic Tac Toe
题目:给定一个3*3的矩阵,是一个井字过三关游戏.开始为X先走,问你这个是不是一个合法的游戏.也就是,现在这种情况,能不能出现.如果有人赢了,那应该立即停止.那么可以知道X的步数和O的步数应该满足x= ...
- 【leetcode】1275. Find Winner on a Tic Tac Toe Game
题目如下: Tic-tac-toe is played by two players A and B on a 3 x 3 grid. Here are the rules of Tic-Tac-To ...
- LeetCode 5275. 找出井字棋的获胜者 Find Winner on a Tic Tac Toe Game
地址 https://www.acwing.com/solution/LeetCode/content/6670/ 题目描述A 和 B 在一个 3 x 3 的网格上玩井字棋. 井字棋游戏的规则如下: ...
- [CareerCup] 17.2 Tic Tac Toe 井字棋游戏
17.2 Design an algorithm to figure out if someone has won a game oftic-tac-toe. 这道题让我们判断玩家是否能赢井字棋游戏, ...
- Epic - Tic Tac Toe
N*N matrix is given with input red or black.You can move horizontally, vertically or diagonally. If ...
- python 井字棋(Tic Tac Toe)
说明 用python实现了井字棋,整个框架是本人自己构思的,自认为比较满意.另外,90%+的代码也是本人逐字逐句敲的. minimax算法还没完全理解,所以参考了这里的代码,并作了修改. 特点 可以选 ...
- ACM-Team Tic Tac Toe
我的代码: #include <bits/stdc++.h> using namespace std; int main() { char a[3][3]; int i,j=0; for( ...
- bnuoj 20832 Calculating Yuan Fen(暴力模拟)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=20832 [题意]: 给你一串字符串,求一个ST(0<ST<=10000),对字符串中字符 ...
随机推荐
- 如何在Typora中使用流程图
1.横向流程图源码格式: graph LR A[方形] -->B(圆角) B --> C{条件a} C -->|a=1| D[结果1] C -->|a=2| E[结果2] A- ...
- pychram 激活码
转自博客:https://blog.csdn.net/may_ths/article/details/84032217 激活码到期时间: 2020.06 K6IXATEF43-eyJsaWNlbnNl ...
- 【LeetCode】387. First Unique Character in a String
Difficulty:easy More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/first-unique-cha ...
- Windows 查看端口占用进程并关闭
当我们在运行一些软件需要特定软件(如tomcat)时,有可能会碰上端口被占用的情况,这时候我们可能就需要更改端口或把占用端口的进程结束掉,因为更换端口可能会导致当前环境产生一些的问题或是需要重新配置其 ...
- 类型和变量(C#学习笔记02)
类型和变量 [C#类型和变量(原文参考官方教程)]https://docs.microsoft.com/zh-cn/dotnet/csharp/tour-of-csharp/types-and-var ...
- 微服务(Microservices)——Martin Flower
原文是 Martin Flower 于 2014 年 3 月 25 日写的<Microservices>. 迁移到:http://www.bdata-cap.com/newsinfo/17 ...
- 连接池未注册org.logicalcobwebs.proxool.ProxoolException: Attempt to refer to a unregistered pool by its alias 'XXX'
代码之前一直好好的,写了一个定时器后报错,本地测试为了立马能执行就用cron表达式* * * * * ?,为了只执行一次在最后面加上Thread.sleep(1000*3600*24)睡眠二十四小时从 ...
- pandas-18 reindex用法
pandas-18 reindex用法 pandas中的reindex方法可以为series和dataframe添加或者删除索引. 方法:serise.reindex().dataframe.rein ...
- mmap vs read
先放个结论: 内存映射通常比随机访问更快,尤其访问的对象是分离的和不可预测的. 内存映射会持续占用pages, 直到完成访问. 这意味当长时间重度使用一个文件很久之前, 然后你关闭了它, 然后再重新打 ...
- 13、vue如何解决跨域问题
开发环境:配置config文件夹中index.js文件: proxyTable: { '/api': { target: 'http://10.10.1.242:8245',//后端地址 // sec ...