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. 【原】cookie和session的区别

    1.存放位置 cookie的数据存放在客户端的浏览器上,session存放在服务器上 2.安全程度 cookie不是很安全,别人通过分析本地的cookie并进行cookie欺骗:考虑到安全应该使用se ...

  2. idea中scala项目补全变量、添加打印语句的小技巧

    1. 自动补全变量: new Person.var  ,然后按回车键:效果:代码变成: val person: Person = new Person 2.添加打印语句: person.name.pr ...

  3. windows网络编程-C语言实现简单的TCP协议聊天

    TCP/IP协议(面向连接协议)类似于打电话时,对方一定在手机附近并且此刻都在和对方进行通话.一定保证双方都在线,才能进行数据传输.UDP/IP协议(无连接协议)就像邮箱,不保证对方一定在等你邮件且对 ...

  4. PHP实现链式操作的三种方法详解

    这篇文章主要介绍了PHP实现链式操作的三种方法,结合实例形式分析了php链式操作的相关实现技巧与使用注意事项,需要的朋友可以参考下 本文实例讲述了PHP实现链式操作的三种方法.分享给大家供大家参考,具 ...

  5. idea修改项目编码

  6. CSS - 精灵Sprite

    1. CSS精灵是一种处理网页背景图像的方式. 2. 它将一个页面涉及到的所有零星背景图像都集中到一张大图中去,然后将大图应用于网页,这样,当用户访问该页面时,只需向服务发送一次请求,网页中的背景图像 ...

  7. 使用外网访问Flask项目

    在学习flask过程中,想使用手机访问项目,根据flask手册中可以将 app.run(host='192.168.1.109', port=8000,debug=True) 但是发现手机依然无法连接 ...

  8. C 语言入门---第十一章---C语言重要知识点补充

    ====C语言typedef 的用法==== 1. C语言允许为一个数据类型起一个新的别名,就像给人起绰号一样. typedef OldName newName; typedef 和 #define ...

  9. C++获取驱动盘句柄

    转载:https://www.cnblogs.com/sherlock-merlin/p/10792116.html     https://univasity.iteye.com/blog/8052 ...

  10. Educational Codeforces Round 73 (Rated for Div. 2)E(思维,博弈)

    //这道题博弈的核心就是不能让后手有一段只能放b而长度不够放a的段,并且先手要放最后一次#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h> ...