zoukankan      html  css  js  c++  java
  • [CTSC2014]企鹅QQ

    再次惨遭卡模数。

    但是为什么自然溢出没有被卡。。。。。。。我好绝望啊

    这道题思路就是枚举断点,然后看看这个断点左右两侧和哈希值都一样的话就是相似的。

    然后就随便判一下即可。

    希望大家不要被卡。。。用自然溢出就行了。。。。

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    using namespace std;
    const int base = 131,mod = 1e9+9;
    int n,l,ds;
    unsigned long long hsh[30005][205][2];
    struct TP{
        unsigned long long x,y;
        bool operator < (const TP &rhs) const {
            return x==rhs.x?y<rhs.y:x<rhs.x;
        }
        bool operator == (const TP &rhs) const {
            return x==rhs.x&&y==rhs.y;
        }
    }tp[30005];
    char ch[205];
    int main() {
        scanf("%d%d%d",&n,&l,&ds);
        for(int i=1;i<=n;i++) {
            scanf("%s",ch+1);
            for(int j=1;j<=l;j++) {
                hsh[i][j][0]=(hsh[i][j-1][0]*base+ch[j]);
            }
            for(int j=l;j;j--) {
                hsh[i][j][1]=(hsh[i][j+1][1]*157+ch[j]);
            }
        }
        long long ans=0;
        for(int i=1;i<=l;i++) {
            for(int j=1;j<=n;j++) {
                tp[j]=(TP){hsh[j][i-1][0],hsh[j][i+1][1]};
            }
            sort(tp+1,tp+n+1);int res=1;
            for(int j=2;j<=n;j++) {
                if(tp[j]==tp[j-1]) ans+=res,res++;
                else res=1;
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    [CTSC2014]企鹅QQ
    我是咸鱼。转载博客请征得博主同意Orz
  • 相关阅读:
    缩减apk大小
    android 的安全问题
    android listview 优化
    Python正则表达式指南
    程序员必须知道的几个国外IT网站
    去掉配置项,开发自信的软件
    去掉配置项,开发自信的软件
    Linux防火墙设置
    Linux防火墙设置
    linux下如何使用sftp命令进行文件上传和下载
  • 原文地址:https://www.cnblogs.com/sdfzhsz/p/9753418.html
Copyright © 2011-2022 走看看