zoukankan      html  css  js  c++  java
  • 雪花雪花雪花

    写过不少, 没了。

    
    #include<bits/stdc++.h>
    using namespace std;
    
    const int maxn = 100005;
    int n, a[maxn][6];
    
    namespace h
    {
        
        int hed[maxn], nxt[maxn], ver[maxn], tot;
        
        int H(int ind)
        {
            int res = 0;
            for(int i=0; i<6; ++i) res = res xor a[ind][i];
            return (res % 100000) + 1;
        }
        
        void ins(int hashval, int b)
        {
            ver[++tot] = b;
            nxt[tot] = hed[hashval];
            hed[hashval] = tot;
        }
        
        bool eq(int inda, int indb)
        {
            bool res = false;
            // double zheng
            for(int i=0; i<6; ++i) for(int j=0; j<6; ++j) {
                bool nowres = true;
                for(int k=0; k<6; ++k) if(a[inda][(i+k)%6] != a[indb][(j+k)%6]) nowres = false;
                res |= nowres;
            }
            // one zheng one fan
            for(int i=0; i<6; ++i) for(int j=0; j<6; ++j) {
                bool nowres = true;
                for(int k=0; k<6; ++k) if(a[inda][(i+k)%6] != a[indb][(j-k+6)%6]) nowres = false;
                res |= nowres;
            }
            return res;
        }
        
        bool travel(int hashval, int ind)
        {
            for(int i=hed[hashval]; i; i=nxt[i]) if( eq(ver[i], ind) ) return true;
            return false;
        }
        
    }
    
    int main()
    {
        
        scanf("%d", &n);
        for(int i=1; i<=n; ++i) {
            for(int j=0; j<6; ++j) scanf("%d", &a[i][j]);
            int Hash = h::H(i);
            if( h::travel(Hash, i) )
            {
                cout << "Twin snowflakes found." ;
                return 0;
            }
            h::ins(Hash, i);
        }
        cout << "No two snowflakes are alike." ;
        return 0;
        
    }
    
    
  • 相关阅读:
    Debugging Kafka connect
    android O 蓝牙设备默认名称更改
    qualcomm sdm450 tinymix mic record
    QACT 在线调试 Android O
    Android O seLinux 编译错误
    Android seLinux 设置
    高通 fastboot 显示
    高通 双MIC 设置
    高通 添加 cmdline
    高通 mixer_paths.xml 音频配置文件 初始化过程
  • 原文地址:https://www.cnblogs.com/tztqwq/p/12243505.html
Copyright © 2011-2022 走看看