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 的网格上玩井字棋. 井字棋游戏的规则如下: ...
随机推荐
- 模拟实现死亡之Ping(Ping of death)
需求描述 使用hping构造IP分片,模拟实现死亡之Ping 环境搭建 使用VMWare和Dynamips. 实现思路 构造重装后大于65535字节的IP分片 hping 192.168.1.1 -1 ...
- 实用js+css多级树形展开效果导航菜单
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- uglifyjs使用
1.安装Nodejs:去这里下载并安装. 2.打开cmd,运行npm,node应该会有输出东西 3.如果在window上运行Node.js的npm报Error: ENOENT, stat 'C:\Us ...
- crontab 每月最后一天
0 8 28-31 * * [ `date -d tomorrow +%e` -eq 1 ] && do-something 我觉得能想到这种方法的,都是经验丰富的人.程序员们,想 ...
- linux xampp eclipse xdebug 无法进入断点
一.xampp 版本 1.8.3-5 xampp安装后会自动集成xdebug,目录一般为 /opt/lampp/lib/php/extensions/***-debug-***目录 关于php 与ph ...
- RESTful HTTP的实践
REST是一种风格,而不是标准.因为既没有REST RFC,也没有REST协议规范或者类似的规定.REST架构是Roy Fielding(他也是HTTP和URI规范的主要作者之一)在一篇论文中描述的. ...
- IOS中UIScrollView的详细使用
UIScrollView 是可以滚动的View 要想让UIScrollView可以滚动,必须设置UIScrollView的contentSize contentSize : 表示UIScrollVie ...
- 项目管理及自动构建工具Maven
项目管理及自动构建工具Maven 一.Maven安装.目录结构.cmd命令1.下载安装apache-maven-3.2.3-bin.zip下载:http://maven.apache.org/down ...
- LeetCode Database: Rank Scores
Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...
- Arduino+RFID RC522 +继电器
博客园的第一篇博文就献给Arduino了.不知道能不能坚持自己喜欢的并且记录下来. 起码是个好的开始. 想实现一卡通代替钥匙开启电动车. 简单的原理,通过RC522模块读取一卡通的序列号,在程序中进行 ...