雪花


题目描述

众所周知,雪花是六边形的。给定 n个雪花各边的长度,但可能从任意一边开始给出,且描述的顺序可能为顺时针或逆时针。例如,相同的雪花可以描述为1 2 3 4 5 6或4 3 2 1 6 5。
请判断:在这些雪花中,是否存在相同的雪花?

输入格式 1814.in

第一行输入将包含一个整数n,0<n≤100000,表示雪花数。下面有n行,每一行描述一个雪花。每行将包含一个雪花的信息,六个整数(每个整数至少为0且小于10000000)的描述,即六边形雪花的每边的长度。
</n≤100000,表示雪花数。下面有n行,每一行描述一个雪花。每行将包含一个雪花的信息,六个整数(每个整数至少为0且小于10000000)的描述,即六边形雪花的每边的长度。

输出格式 1814.out

如果所有的雪花都不同,您的程序应该打印消息:
No two snowflakes are alike.
如果有一对可能相同的积雪,您的程序应该打印消息:
Twin snowflakes found.

输入样例 1814.in

2
1 2 3 4 5 6
4 3 2 1 6 5

输出样例 1814.out

Twin snowflakes found.

 

    这题不太难,输入一个雪花以后,只要把顺时针和逆时针的方向都记一次就好了。以第一朵雪花为下标存。然后找在哈希表里面有没有一样的,如果有,就直接输出Twin snowflakesfound.然而,只有55分。。

#include
   
   
    
    
#include
    
    
     
     
#include
     
     
      
      
#include
      
      
       
       
using namespace std;
int a[7],news[7],prime=2000003,n,f;
struct point
{
	int now[7];
};
vector
       
       
         hash[2000010]; int find(int x) { int y=x%prime; int size=hash[y].size(); for(int i=0;i 
        
          6) nn=1; } if(find(news[1])==1) { cout<<"Twin snowflakes found."< 
         
           =1;first--) { int times=0,nn=first; while(times<6) { times++; news[times]=a[nn]; nn--; if(nn<1) nn=6; } if(find(news[1])==1) { cout<<"Twin snowflakes found."< 
          
            >n; for(int i=1;i<=n;i++) { for(int j=1;j<=6;j++) { cin>>a[j]; } shun(); if(f==1) return 0; memset(news,0,sizeof(news)); ni(); if(f==1) return 0; } cout<<"No two snowflakes are alike."< 
            
           
          
         
       
      
      
     
     
    
    
   
   
走过路过的大神帮忙看看,为什么啊。。

新代码:

#include
    
    
     
     
#include
     
     
      
      
#include
      
      
       
       
#include
       
       
        
        
using namespace std;
int a[7],news[7],prime=2000003,n,f;
struct point
{
	int now[7];
};
vector
        
        
          hash[2000010]; int find(int x) { int y=x%prime; int size=hash[y].size(); for(int i=0;i 
         
           6) nn=1; } if(find(news[1])==1) { cout<<"Twin snowflakes found."< 
          
            =1;first--) { int times=0,nn=first; while(times<6) { times++; news[times]=a[nn]; nn--; if(nn<1) nn=6; } cun(news[1]); } } int main() { // freopen("1814.in","r",stdin); // freopen("1814.out","w",stdout); ios::sync_with_stdio(false); cin>>n; for(int i=1;i<=n;i++) { for(int j=1;j<=6;j++) { cin>>a[j]; } cha(); if(f==1) return 0; cc(); } cout<<"No two snowflakes are alike."< 
            
           
          
        
       
       
      
      
     
     
    
    

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值