2017 青岛网络赛 Chenchen, Tangtang and ZengZeng
Chenchen, Tangtang and ZengZeng are starting a game of tic-tac-toe, played on a 3 × 3 board.
Initially, all squares on the board are empty and they takes turns writing the first letter of their name into any of the empty squares (because Chenchen, Tangtang and ZengZeng are elites, their names have different first letters, ’C’, ’T’ and ’Z’ respectively). The game ends when anyone of them places 3 of his letters consecutively in a row, column or diagonally. That people is declared the winner.
Write a program that, given the state of the board, determines if the game is over and who won if it is.
Input
The input contains several test cases up to 1000. Each case contains three lines describing the board. Each line contains 3 characters. The characters will be uppercase letters of {′C′,′ T′,′ Z′} or ’.’ (if the square is empty). The data will be such that there is at most one winner
Output
For each case, if the game is over, output the first letter of the winner’s name. If not, output “ongoing” even if the board if full.
样例输入复制
4
CTZ
TCZ
CTZ
ZCT
CZC
TTZ
.C.
C.T
Z..
CTZ
.C.
CTZ
样例输出复制
Z
Z
ongoing
ongoing 题意:一个三行三列的棋盘,规则和五子棋一样,Z,C,T代表三个人,.代表空位置,输出赢得那个人得名字
#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<string>
#include<string.h>
#include<vector>
#include<utility>
#include<map>
#include<queue>
#include<set>
#define mx 0x3f3f3f3f
#define ll long long
using namespace std;
string s[];
int main()
{
int t;
cin>>t;
while(t--)
{
for(int i=;i<;i++)
cin>>s[i];
int flag=;
for(int i=;i<;i++)
{
if(s[i][]==s[i][]&&s[i][]==s[i][]&&s[i][]!='.')//行
{
cout<<s[i][]<<endl;
flag=;
break;
}
else if(s[][i]==s[][i]&&s[][i]==s[][i]&&s[][i]!='.')//列
{
cout<<s[][i]<<endl;
flag=;
break;
}
else if(s[][]==s[][]&&s[][]==s[][]&&s[][]!='.')//主对角线
{
cout<<s[][]<<endl;
flag=;
break;
}
else if(s[][]==s[][]&&s[][]==s[][]&&s[][]!='.')//副对角线
{
cout<<s[][]<<endl;
flag=;
break;
}
}
if(flag==)
cout<<"ongoing"<<endl;
}
return ;
}
2017 青岛网络赛 Chenchen, Tangtang and ZengZeng的更多相关文章
- HDU 6212 Zuma 2017青岛网络赛 区间DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6212 解法:看了眼题就发现这个BZOJ 1032不是一毛一样?但是BZOJ上那是个巨坑,数据有错,原来 ...
- 2017青岛网络赛1011 A Cubic number and A Cubic Number
A Cubic number and A Cubic Number Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/3276 ...
- 2017青岛网络赛1008 Chinese Zodiac
Chinese Zodiac Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) T ...
- HDU 5880 Family View (2016 青岛网络赛 C题,AC自动机)
题目链接 2016 青岛网络赛 Problem C 题意 给出一些敏感词,和一篇文章.现在要屏蔽这篇文章中所有出现过的敏感词,屏蔽掉的用$'*'$表示. 建立$AC$自动机,查询的时候沿着$fa ...
- 2017乌鲁木齐网络赛 j 题
题目连接 : https://nanti.jisuanke.com/t/A1256 Life is a journey, and the road we travel has twists and t ...
- hdu 6152 : Friend-Graph (2017 CCPC网络赛 1003)
题目链接 裸的结论题.百度 Ramsey定理.刚学过之后以为在哪也不会用到23333333333,没想到今天网络赛居然出了.顺利在题面更改前A掉~~~(我觉得要不是我开机慢+编译慢+中间暂时死机,我还 ...
- 2017 ICPC网络赛(西安)--- Xor
题目连接 Problem There is a tree with n nodes. For each node, there is an integer value ai, (1≤ai≤1,000 ...
- 2017 青岛现场赛 Suffix
Consider n given non-empty strings denoted by s1 , s2 , · · · , sn . Now for each of them, you need ...
- 2017 青岛现场赛 I The Squared Mosquito Coil
Lusrica designs a mosquito coil in a board with n × n grids. The mosquito coil is a series of consec ...
随机推荐
- 一、FreeMarker实现对js和css压缩
1.代码压缩理解:实际上就是将原有的文本中无用的注释.空行.空格去掉来压缩文件的大小.进行js和css压缩会带来如下好处:1)减小了文件的体积,减少文件占用的内存;2)减小了网络传输量和带宽占用; 3 ...
- 测试Nginx中location的优先级!(重点)
location [=|~|~*|^~] /uri/ { … } = 开头表示精确匹配 ~ 开头表示区分大小写的正则匹配 ~* 开头表示不区分大小写的正则匹配 ^~ 开头表示uri以某个常规字符串开头 ...
- header头中 content-type的作用
- iOS项目开发日常之创建文件(协议、类、分类、扩展)
iOS项目开发过程中,是以不断创建文件的形式进行着的. 创建得比较频繁的文件类型是: 这两个类型中创建的文件有:子类.分类.扩展.协议四种文件,如下: 这四类文件是频繁创建的,我们来看一下各自分 ...
- @implementer,抽象类,接口
@implementer,抽象类,接口 1. implementer 在看twisted源码时,经常出现@implementer(IReactorFDSet) 它来自zope.interfa ...
- Java基础 -2.5
布尔数据boolean类型 布尔类型的取值范围只有两个数据:true false. public class ddd { public static void main(String[] args) ...
- SpringMvc 视图解析器常见功能、类型转换、格式化
springmvc.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=" ...
- 实现JSP部分内容继承
我们的网站框架搭好以后,只需要主体部分显示不同的数据. 如果每次代码重写都会造成冗余. 今天欣赏别人代码,学到了 maven 核心代码 <dependency> <groupId&g ...
- yolo系列目标检测+自标注数据集进行目标识别
1. yolov1的识别原理 参考:https://blog.csdn.net/u010712012/article/details/85116365 https://blog.csdn.net/gb ...
- 5.1 Nginx的基本配置
备注:worker_processes 1(数量建议跟系统CPU的核数相同,例如:2个CPU,每个CPU4核,建议为8),worker_connections 建议小于worker_rlimit_no ...