哈希-poj-3349-相同的雪花

poj-3349-Snowflake Snow Snowflakes

Time Limit: 4000MS  Memory Limit: 65536K 

Description

You may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really true. Your program will read information about a collection of snowflakes, and search for a pair that may be identical. Each snowflake has six arms. For each snowflake, your program will be provided with a measurement of the length of each of the six arms. Any pair of snowflakes which have the same lengths of corresponding arms should be flagged by your program as possibly identical.

Input

The first line of input will contain a single integer n, 0 < n ≤ 100000, the number of snowflakes to follow. This will be followed by n lines, each describing a snowflake. Each snowflake will be described by a line containing six integers (each integer is at least 0 and less than 10000000), the lengths of the arms of the snow ake. The lengths of the arms will be given in order around the snowflake (either clockwise or counterclockwise), but they may begin with any of the six arms. For example, the same snowflake could be described as 1 2 3 4 5 6 or 4 3 2 1 6 5.

Output

If all of the snowflakes are distinct, your program should print the message:

No two snowflakes are alike.

If there is a pair of possibly identical snow akes, your program should print the message:

Twin snowflakes found.

Sample Input

2

1 2 3 4 5 6

4 3 2 1 6 5

Sample Output

Twin snowflakes found.

 

 

 

 

 

 

 

时间: 2024-08-21 19:20:21

哈希-poj-3349-相同的雪花的相关文章

POJ 3349 Snowflake Snow Snowflakes 链表

       题目不太难,方法有两种,一直是直接爆搜,用stl会超时,要手写链表.          第二种是排个序,我的想法是按从最小开始的升序排序,这要注意像212313,111221,这类的数据.      排序的方法搞了好久,但是一直WA,最后貌似是stl里map的问题,那样就要手写hash了,但是因为数据太大,hash函数不好构造,所以可以用排序加二分,后来太懒了于是直 接手写链表爆搜了.     代码比较挫就不贴了

A题常用数据结构

  基本结构 高级结构 题单 集合结构   幷查集 POJ 1182 POJ 1308 POJ 1611 POJ 1986 POJ 1988 线性结构 数组 栈 队列 双端队列 POJ POJ POJ POJ POJ 树状结构 二叉树 BST AVL树 splay树(伸展树) Treap Cartesian Tree Size Balance Tree POJ 3580(splay tree) POJ 2761(Treap) POJ 2201(Cartesian Tree) POJ 3481(S

poj系统训练计划

转载:http://www.cnblogs.com/silveryelf/archive/2011/10/29/2228681.html 初级: 基本算法: 枚举:1753    2965 贪心:1328    2109    2586 构造:3295 模拟:1068    2632    1573    2993    2996 图: 最短路径:1860    3259    1062    2253    1125    2240 最小生成树:1789    2485    1258    

POJ题目分类

初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      (4)递推.      (5)构造法.(poj3295)      (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996) 二.图算法:      (1)图的深度优先遍历和广度优先遍历.      (2)最短路径算法(dijkstra,bellman-ford

poj 1733 Parity game:带权并查集

链接: http://poj.org/problem?id=1733 题目: Description Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequence from the

POJ 1077 Eight:八数码问题

题目链接: http://poj.org/problem?id=1077 题目类型: 隐式图搜索 原题: The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and all pac

poj分类

初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      (4)递推.      (5)构造法.(poj3295)      (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996) 二.图算法:      (1)图的深度优先遍历和广度优先遍历.      (2)最短路径算法(dijkstra,bellman-ford

uva 652---Eight Poj 1077 ---Eight zoj 1217---Eight (八数码解法2)

点击打开链接uva 652 点击打开链接hdu 1043 点击打开链接zoj 1217                                                              八数码解法2 解题整体思路 :    预处理+哈希判重+打表+输出路径                               我们知道对于八数码问题而言,每一个状态就是每一个格子的编号(我们把空格看成9),那么最多有9!种,那么现在针对每一种状态都有9个数字,难道我们开一个9维数组,

uva 652---Eight Poj 1077 ---Eight zoj 1217---Eight (八数码解法3)

点击打开链接uva 652 点击打开链接hdu 1043 点击打开链接zoj 1217                                                              八数码解法3 解题整体思路 :    双向广搜+哈希判重+输出路径                      (目前只能AC poj 数据水了不解释,其它的OJ一直TLE,求教)                               我们知道对于八数码问题而言,每一个状态就是每一个格