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 ...
随机推荐
- java编译中出现了Exception in thread “main" java.lang.UnsupportedClassVersionError
这个问题确实是由较高版本的JDK编译的java class文件试图在较低版本的JVM上运行产生的错误. 1.解决措施就是保证jvm(java命令)和jdk(javac命令)版本一致.如果是linux版 ...
- 如果你是新晋的leader, 你可能需要了解这些。
背景 在职业发展的道路上,我们总会面临这样的抉择: 是在技术的路上一条路走到黑,做技术专家 接触管理, 走上管理 年龄大了,搬砖没人要,转型 or 去公司楼下卖炒粉 我曾经有个小小的愿望: 在毕业5年 ...
- 循环读取寄存器(QSFP-DD)并且分别保存log
#!/bin/bash ####################################################################### #Created by: Bin ...
- Django--redis 保存session
pipenv install django-redis settings.py: # 作为 cache backend 使用配置 使用redis保存session CACHES = { "d ...
- IDEA工具java开发之 常用插件 git插件 追加提交 Code Review==代码评审插件 撤销提交 撤销提交 关联远程仓库 设置git 本地操作
◆git 插件 请先安装git for windows ,git客户端工具 平时开发中,git的使用都是用可视化界面,git命令需要不时复习,以备不时之需 1.环境准备 (1)设置git (2)本地操 ...
- 「SPOJ10707」Count on a tree II
「SPOJ10707」Count on a tree II 传送门 树上莫队板子题. 锻炼基础,没什么好说的. 参考代码: #include <algorithm> #include &l ...
- Python使用正则表达式(Regular Expression)超详细
一.导入re库 python使用正则表达式要导入re库. import re在re库中.正则表达式通常被用来检索查找.替换那些符合某个模式(规则)的文本.ps:另外很多人在学习Python的过程中,往 ...
- SQL注入之SQLmap
注意:sqlmap只是用来检测和利用sql注入点的,并不能扫描出网站有哪些漏洞,使用前请先使用扫描工具扫出sql注入点. 1.
- [Linux] day03——REHL部署
REHL 部署 Linux 树形目录结构 最顶层 根 / 在Linux中 一切皆文件 文件系统 swap / 安装方式 PXE U盘 光盘 配置安装程序 选择包 5.9 6.4
- sqlserver链接字符串
string connectionStr = "Data Source=LJJ-FF\\LJJ;Initial Catalog=TestDapper;User ID=sa;Password= ...