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. Linux OS 集群 免密登录

    1. ssh-keygen  生成密钥 2. ssh-copy-id  集群主机名 参考: [图文详解]linux下配置远程免密登录

  2. C++11特性中基于范围的for循环

    本文摘录柳神笔记:   除了像C语⾔的for语句 for (i = 0; i < arr.size(); i++) 这样,C++11标准还为C++添加了⼀种新的 for 循环⽅ 式,叫做基于范围 ...

  3. JS动态添加删除html

    本功能要求是页面传一个List 集合给后台而且页面可以动态添加删除html代码需求如下: 下面是jsp页面代码 <%@ page language="java" pageEn ...

  4. HD Tune检查硬盘各参数的含义

    01 =Read Error Rate / (底层)数据读取错误率指从磁盘表面读取数据时发生的硬件读取错误的比率,Raw值对于不同的厂商有着不同的体系,单纯看做1个十进制数字是没有任何意义的.以上为W ...

  5. zookeeper 启动和停止脚本

    启动 sh zkServer.sh start 停止脚本 sh zkServer.sh stop

  6. mybatis升级案例之CRUD操作

    mybatis升级案例之CRUD操作 一.准备工作 1.新建maven工程,和入门案例一样 主要步骤如下,可参考mybatis入门实例 a.配置pom.xml文件 b.新建实例类User.DAO接口类 ...

  7. 爬虫(十四):Scrapy框架(一) 初识Scrapy、第一个案例

    1. Scrapy框架 Scrapy功能非常强大,爬取效率高,相关扩展组件多,可配置和可扩展程度非常高,它几乎可以应对所有反爬网站,是目前Python中使用最广泛的爬虫框架. 1.1 Scrapy介绍 ...

  8. Nessus忘记用户名和密码

    以管理员身份运行cmd,切换到Nessus的安装目录,执行以下操作.

  9. nginx的addition模块在响应的前后报文添加内容与变量的运行原理

    nginx默认未编译此模块:让nginx编译启用此模块 ./configure --prefix=/data/web --sbin-path=/usr/bin --user=nginx --group ...

  10. svn 回退/更新/取消某个版本命令详解

    1,取消文件: svn revert 文件名 2,取消目录 svn revert --depth=infinity 目录名 3,回退版本 方法1: 用svn merge 1) 先svn up,保证更新 ...