POJ 3349 Snowflake Snow Snowflakes
SnowflakeSnowSnowflakes
Time Limit:4000 MS |
|
Memory Limit:65536 K |
Total Submissions:35235 |
|
Accepted:9266 |
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 shocould be flagged by your program as possibly identical.
Input
The first line of input will contain a single integerN, 0 <N≤ 100000, the number of snowflakes to follow. This will be followedNLines, 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 cocould 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 shocould print the message:
No two snowflakes are alike.
If there is a pair of possibly identical snow akes, your program shocould print the message:
Twin snowflakes found.
Sample Input
21 2 3 4 5 64 3 2 1 6 5
Sample Output
Twin snowflakes found.
Source
CCC 1, 2007
ACcode
#include
# Include # Include # Include # Include # Include # Include # Include # define maxn 99809 using namespace std; int hash [maxn]; struct Sonw {int a [6]; int in () {int sum = 0; for (int I = 0; I <6; ++ I) {scanf (% d, & a [I]); sum + = a [I];} return sum % = maxn ;}}; Sonw m [maxn] [2], t; int cmp (Sonw x, Sonw y) {int st, I, j; for (st = 0; st <6; st ++) {for (I = st, j = 0; j <6; j ++, I = (I + 1) % 6) {if (x. a [I]! = Y. a [j]) break;} if (j = 6) return 1;} for (st = 0; st <6; st ++) {for (I = st, j = 0; j <6; j ++, I = (I + 5) % 6) {if (x. a [I]! = Y. a [j]) break;} if (j = 6) return 1;} return 0;} int main () {int n; scanf (% d, & n ); int pos; bool flag = true; while (n --) {pos = t. in (); // cout <