uva 11967 - Hic-Hac-Hoe
来源:互联网 发布:软件加人规则 编辑:程序博客网 时间:2024/05/22 22:44
Q — Hic-Hac-Hoe
Time Limit: 2 sec
Memory Limit: 32 MB
Everybody knows how to play tic-tac-toe. If accidentally you do not know the rules of this game, you can always consult Wikipedia.
In this problem we will use a slightly different version of tic-tac-toe. First, the game board is not limited to 3x3 cells, but considered infinite. Also in order to win a player must get not 3 but at least knoughts or crosses in a line (horizontal, vertical or diagonal).
In modified tic-tac-to version it is not so easy to determine a winner. So in this problem you will be given a list of turns performed by the players during the game and you need to determine the winner.
INPUT
There is a number of tests T
(T ≤ 100) on the first line. Each test case is described by the two numbers n k
(n ≤ 105, k ≤ 5), where n
stands for number of turns for both players and k
for winning line size. Next line contains n
pairs of signed 32-bit integers x y
— coordinates of each players turn. All turns have been performed sequentially by both players and crosses have always started a game.
OUTPUT
For each test case output a single line "Case T: S"
. Where T
is the test case number (starting from 1) and S
is equal to "crosses"
or "noughts"
if one of them has a winning line. If nobody yet has won a game output"none"
and if both players have winning lines output "error"
for "S"
.
SAMPLE INPUT
23 20 0 1 1 1 04 20 0 -1 0 1 1 -1 1
SAMPLE OUTPUT
Case 1: crossesCase 2: error
Problem by: Aleksej Viktorchik; Leonid Sislo
Huge Easy Contest #2
水题一道,在无限大的棋盘上玩hic-hac-hoe,用map存,然后枚举每个点,最多八个方向拓展k步。
#include <cstdio>#include <algorithm>#include <vector>#include <map>#include <queue>#include <iostream>#include <stack>#include <set>#include <cstring>#include <stdlib.h>#include <cmath>using namespace std;typedef long long LL;typedef pair<int, int> P;const int maxn = 100 + 5;int n, k;map<P, int> M;vector<P> v;bool judge(int x, int y){ int kind = M[P(x, y)]; // right int tag = 1; for(int i = 1;i < k;i++){ int tx = x+i; int ty = y; if(M.count(P(tx, ty)) == 0 || M[P(tx, ty)] != kind){ tag = 0; break; } } if(tag) return true; // left tag = 1; for(int i = 1;i < k;i++){ int tx = x-i; int ty = y; if(M.count(P(tx, ty)) == 0 || M[P(tx, ty)] != kind){ tag = 0; break; } } if(tag) return true; //up tag = 1; for(int i = 1;i < k;i++){ int tx = x; int ty = y+i; if(M.count(P(tx, ty)) == 0 || M[P(tx, ty)] != kind){ tag = 0; break; } } if(tag) return true; //down tag = 1; for(int i = 1;i < k;i++){ int tx = x; int ty = y-i; if(M.count(P(tx, ty)) == 0 || M[P(tx, ty)] != kind){ tag = 0; break; } } if(tag) return true; //right up tag = 1; for(int i = 1;i < k;i++){ int tx = x+i; int ty = y+i; if(M.count(P(tx, ty)) == 0 || M[P(tx, ty)] != kind){ tag = 0; break; } } if(tag) return true; //left up tag = 1; for(int i = 1;i < k;i++){ int tx = x-i; int ty = y+i; if(M.count(P(tx, ty)) == 0 || M[P(tx, ty)] != kind){ tag = 0; break; } } if(tag) return true; //right down tag = 1; for(int i = 1;i < k;i++){ int tx = x+i; int ty = y-i; if(M.count(P(tx, ty)) == 0 || M[P(tx, ty)] != kind){ tag = 0; break; } } if(tag) return true; //left down tag = 1; for(int i = 1;i < k;i++){ int tx = x-i; int ty = y-i; if(M.count(P(tx, ty)) == 0 || M[P(tx, ty)] != kind){ tag = 0; break; } } if(tag) return true; return false;}int main(){ int t, kase = 0; scanf("%d", &t); while(t--){ kase++; scanf("%d%d", &n, &k); M.clear(); v.clear(); for(int i = 0;i < n;i++){ int x, y; scanf("%d%d", &x, &y); M[P(x, y)] = i%2; v.push_back(P(x, y)); } int tagc = 0, tagn = 0; for(int i = 0;i < n;i++){ if(judge(v[i].first, v[i].second)){ if(i%2 == 0) tagc = 1; else tagn = 1; } } printf("Case %d: ", kase); if(tagc == 1 && tagn == 1){ printf("error\n"); } else if(tagc == 0 && tagn == 0){ printf("none\n"); } else if(tagc == 1){ printf("crosses\n"); } else{ printf("noughts\n"); } } return 0;}
- uva 11967 - Hic-Hac-Hoe
- HOE TO USE GDB
- c++ hac例子
- 关于FCC认证的HAC
- Java 基础操作库 hoe 使用介绍
- 运维安全审计系统HAC
- 层次凝聚聚类算法(HAC)
- 【工作总结】HAC-UM无线数传模块使用总结
- 运动跟踪算法CMT(续)之层次凝聚聚类算法(HAC)
- 杭电OJ(HDU)-ACM Steps-Chapter Two-《Biker's Trip Odometer》《Climbing Worm》《hide handkerchief》《Nasty Hac》
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- UVA
- UVA
- reds 2 之 hiredis
- 定积分解法
- hdu 2066 一个人的旅行_最短路
- 微软面试100题之第4题
- event.preventDefault() 取消事件的默认行为
- uva 11967 - Hic-Hac-Hoe
- 工科男崎岖的求职之路--计算机、银行、公务员
- ubuntu 14.04为/检查磁盘时发生严重错误的解决方法
- ubuntu下安装firefox的flash插件
- JNDI 是什么
- Java的内存泄露
- Java利用Zxing生成二维码
- SqlServer中的数据类型UniqueIdentifier
- Django的url用法