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的更多相关文章

  1. HDU 6212 Zuma 2017青岛网络赛 区间DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6212 解法:看了眼题就发现这个BZOJ 1032不是一毛一样?但是BZOJ上那是个巨坑,数据有错,原来 ...

  2. 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 ...

  3. 2017青岛网络赛1008 Chinese Zodiac

    Chinese Zodiac Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) T ...

  4. HDU 5880 Family View (2016 青岛网络赛 C题,AC自动机)

    题目链接  2016 青岛网络赛  Problem C 题意  给出一些敏感词,和一篇文章.现在要屏蔽这篇文章中所有出现过的敏感词,屏蔽掉的用$'*'$表示. 建立$AC$自动机,查询的时候沿着$fa ...

  5. 2017乌鲁木齐网络赛 j 题

    题目连接 : https://nanti.jisuanke.com/t/A1256 Life is a journey, and the road we travel has twists and t ...

  6. hdu 6152 : Friend-Graph (2017 CCPC网络赛 1003)

    题目链接 裸的结论题.百度 Ramsey定理.刚学过之后以为在哪也不会用到23333333333,没想到今天网络赛居然出了.顺利在题面更改前A掉~~~(我觉得要不是我开机慢+编译慢+中间暂时死机,我还 ...

  7. 2017 ICPC网络赛(西安)--- Xor

    题目连接 Problem There is a tree with n nodes. For each node, there is an integer value ai, (1≤ai​≤1,000 ...

  8. 2017 青岛现场赛 Suffix

    Consider n given non-empty strings denoted by s1 , s2 , · · · , sn . Now for each of them, you need ...

  9. 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 ...

随机推荐

  1. Jmeter 如何发起一个Get请求

    举例平台:https://www.juhe.cn/docs/api/id/65 前提条件: 1)要在聚合网站注册实名认证才可以收到Key,用于Get请求的参数数值 2)Jmeter本地安装好 3.这是 ...

  2. 一、FreeMarker实现对js和css压缩

    1.代码压缩理解:实际上就是将原有的文本中无用的注释.空行.空格去掉来压缩文件的大小.进行js和css压缩会带来如下好处:1)减小了文件的体积,减少文件占用的内存;2)减小了网络传输量和带宽占用; 3 ...

  3. ssh pubkey免密登陆远程主机

    二.公钥登录 每次登录远程主机都需要输入密码是很不方便的,如果想要省去这一步骤,可以利用密钥对进行连接,还可以提高安全性. 1.在本机生成密钥对 使用ssh-keygen命令生成密钥对: ssh-ke ...

  4. golang数据库操作初体验

    在golang中,提供了标准的数据库接口database/sql包,做过数据库开发的应该知道,不同的数据库有不同的数据库驱动.比如mysql等,我们可以去找 https://golang.org/s/ ...

  5. Chrome浏览器 无需安装插件将整个网页另存为图片

    步骤1 ctrl+shift+i 步骤2 ctrl+shift+p 步骤3 输入full 回车确定 感谢先辈们的无私奉献!原文https://blog.csdn.net/wumingid/articl ...

  6. C、C++ 不得宠,微软正开发新的编程语言!

    76 年迭代与更新,编程语言界,谁主沉浮? 在六百多种编程语言中,对于开发者而言,其主观印象中或只有几种主流的编程语言,如 Java.C.C++.C#.新贵 Python 等,而之所以它们能够成为主流 ...

  7. linux 从一台机器复制文件到另一台linux机器上去

    1.功能说明scp就是security copy,用于将文件或者目录从一个Linux系统拷贝到另一个Linux系统下.scp传输数据用的是SSH协议,保证了数据传输的安全,其格式如下:scp 远程用户 ...

  8. vb.net与vb的区别

    本文链接:https://blog.csdn.net/dfshsdr/article/details/63255645最近接触了vb.net,它增加了vb的很多特性,而且演化成为完全面向对象的编程语言 ...

  9. 图像分割利用KMeans生成灰度图

    import numpy as np import PIL.Image as image from sklearn.cluster import KMeans def loadData(filePat ...

  10. 使用 C++ 处理 JSON 数据交换格式

    一.摘要 JSON 的全称为:JavaScript Object Notation,顾名思义,JSON 是用于标记 Javascript 对象的,JSON 官方的解释为:JSON 是一种轻量级的数据传 ...