cf754 B. Ilya and tic-tac-toe game
呵呵呵,这个题简直是一直在乱做,真是最近太弱了
#include<bits/stdc++.h>
#define lowbit(x) x&(-x)
#define LL long long
#define N 200005
#define M 1000005
#define mod 2147483648LL
#define inf 0x7ffffffff
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>''){if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<=''){x=x*+ch-''; ch=getchar();}
return x*f;
}
int a[][];
bool can(int x, int y)
{
if (x< || x>) return ;
if (y< || y>) return ;
return ;
}
bool check(int x, int y)
{
int tot=a[x][y];
tot+=a[x-][y];
tot+=a[x+][y];
if (tot>=) return ; tot=a[x][y];
tot+=a[x][y-];
tot+=a[x][y+];
if (tot>=) return ; tot=a[x][y];
tot+=a[x-][y-];
tot+=a[x+][y+];
if (tot>=) return ; tot=a[x][y];
tot+=a[x-][y+];
tot+=a[x+][y-];
if (tot>=) return ;
return ;
}
int main()
{
for (int i=; i<=; i++)
for (int j=; j<=; j++)
a[i][j]=-;
for (int i=; i<=; i++)
{
string ch; cin>>ch;
for (int j=; j<=; j++)
{
if (ch[j-]=='x') a[i][j]=;
if (ch[j-]=='.') a[i][j]=;
}
}
for (int i=; i<=; i++)
for (int j=; j<=; j++)
{
if ((a[i][j]== || a[i][j]==) && check(i,j))
{
cout<<"YES";
return ;
}
}
cout<<"NO";
return ;
}
cf754 B. Ilya and tic-tac-toe game的更多相关文章
- 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 ...
- 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 ...
- [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( ...
- LeetCode 5275. 找出井字棋的获胜者 Find Winner on a Tic Tac Toe Game
地址 https://www.acwing.com/solution/LeetCode/content/6670/ 题目描述A 和 B 在一个 3 x 3 的网格上玩井字棋. 井字棋游戏的规则如下: ...
随机推荐
- Linux C double linked for any data type
/************************************************************************** * Linux C double linked ...
- Android解惑 - 为什么要用Fragment.setArguments(Bundle bundle)来传递参数(转)
Fragment在Android3.0开始提供,并且在兼容包中也提供了Fragment特性的支持.Fragment的推出让我们编写和管理用户界面更快捷更方便了. 但当我们实例化自定义Fragmen ...
- Sublime 的中文乱码问题
Sublime Text 是现在最受欢迎的文本编辑器,没有之一.它非常简洁,而且对各种代码的高亮显示很美观.但是,它默认不支持 GBK.Shift-JIS 等中文.日本编码格式,故打开此类文件会出现乱 ...
- 【英语】Bingo口语笔记(2) - 吞音
- 关闭iptables(Centos)
由于搭建了CDH-Hadoop,方便起见,事先关闭了防火墙: services iptables stop; chkconfig iptables off; services ip6tables st ...
- HDFS命令行文件操作
Hadoop文件操作命令形式为 hadoop fs -cmd <args> 说明:cmd是具体的文件操作命令,<args>是一组数目可变的参数. Hadoop最常用的文件操作命 ...
- 在centOS中加入本地ISO yum源
注:本文转载自<liujun_live的博客>,感谢原博主的辛勤写作:原文地址:http://blog.sina.com.cn/s/blog_8ea8e9d50101em6f.html 在 ...
- Android应用性能优化之使用SQLiteStatement优化SQLite操作
平常在做Android数据库操作时,都是用的execSQL之个方法. 今天偶然发现了SQLiteStatement这个类.让我想起了在做Java Web开发写JDBC的代码时Prestatement这 ...
- android操作文件
Android中读取/写入文件的方法,与Java中的I/O是一样的,提供了openFileInput()和openFileOutput()方法来读取设备上的文件.但是在默认状态下,文件是不能在不同的程 ...
- Yii系列教程(四):使用Memcache保存会话
1环境准备 安装Memcached服务端: yum -y installmemcached.x86_64 安装PHP-Memcache扩展: yum -y installphp-pecl-memcac ...