Codeforces Beta Round #48 A. Cheaterius's Problem

A. Cheaterius's Problem
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Cheaterius is a famous in all the Berland astrologist, magician and wizard, and he also is a liar and a cheater. One of his latest inventions is Cheaterius' amulets! They bring luck and wealth, but are rather expensive. Cheaterius makes them himself. The technology of their making is kept secret. But we know that throughout long nights Cheaterius glues together domino pairs with super glue to get squares 2 × 2 which are the Cheaterius' magic amulets!

That's what one of Cheaterius's amulets looks like

After a hard night Cheaterius made n amulets. Everyone of them represents a square 2 × 2, every quarter contains 1 to 6 dots. Now he wants sort them into piles, every pile must contain similar amulets. Two amulets are called similar if they can be rotated by 90, 180 or 270 degrees so that the following condition is met: the numbers of dots in the corresponding quarters should be the same. It is forbidden to turn over the amulets.

Write a program that by the given amulets will find the number of piles on Cheaterius' desk.

Input

The first line contains an integer n (1 ≤ n ≤ 1000), where n is the number of amulets. Then the amulet's descriptions are contained. Every description occupies two lines and contains two numbers (from 1 to 6) in each line. Between every pair of amulets the line "**" is located.

Output

Print the required number of piles.

Sample test(s)
input
4
31
23
**
31
23
**
13
32
**
32
13
output
1
input
4
51
26
**
54
35
**
25
61
**
45
53
output
2
 
        
 
        
这个题目是很水的,可是我不觉得是件很容易的事情,不单单是数字一样就可以的,因为这个魔方的排列是有顺序的,所以相同的就是abcd,bcda,cdab,dabc等等就是了
 
        
 
        
#include <stdio.h>
#include <string.h>
#include <string>
#include <queue>
#include <deque>
#include <vector>
#include <iostream>
#include <limits.h>
#include <map>

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)

using namespace std;

struct data
{
      int a;
      int b;
      int c;
      int d;
}dice[1005];

int n;
int pile=0;
bool found;
data new_dice;

char one[3],two[3];

bool check(data i,data j)
{
     bool same=false;
    int ar[10];
    ar[0] = ar[4] = i.a;
    ar[1] = ar[5] = i.b;
    ar[2] = ar[6] = i.c;
    ar[3] = ar[7] = i.d;
    
  
    for (int t=0;t<4;t++)
    {
  
        if (ar[t]==j.a && ar[t+1]==j.b && ar[t+2]==j.c && ar[t+3]==j.d)
        {
           same = true;
           break;
        }
    }

     
     return same;
}

int main()
{
      scanf("%d",&n);
      for (int i=0;i<n;i++)
      {
         scanf("%s",one);
         if (one[0]!='*') scanf("%s",two);
         else
         {
             i--;
             continue;
         }
         
         new_dice.a = one[0]-48;
         new_dice.b = one[1]-48;
         new_dice.c = two[1]-48;
         new_dice.d = two[0]-48;
         
         found = false;
         for (int j=0;j<pile;j++)
         {
             if (check(new_dice,dice[j]))
             {
                found = true;
                break;
             }
         }
         
         if (!found)
         {
            dice[pile] = new_dice;
            pile++;    
         }
         
         
       
      }    
      
      printf("%d\n",pile);
    
    

}


 
        
 
        
 
        
 
        
 
        
 
        
 
        
 
       

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值