zoukankan      html  css  js  c++  java
  • 【CTSC2014】企鹅QQ

    题面

    https://www.luogu.org/problem/P4503

    题解

    #include<cstdio>
    #include<iostream>
    #include<cstring>
    #include<algorithm>
    #define uLL unsigned long long
    #define ri register int
    #define N 30050
    #define L 205
    #define p1 107
    #define p2 233
    using namespace std;
    
    uLL A1[N][L],A2[N][L],B1[N][L],B2[N][L];
    int id[N];
    char s[N][L];
    int n,l,ss;
    int sani;
    
    bool cmp(int x,int y){
      return (A1[x][sani-1]<A1[y][sani-1] || A1[x][sani-1]==A1[y][sani-1] && A2[x][sani-1]<A2[y][sani-1]
      || A1[x][sani-1]==A1[y][sani-1] && A2[x][sani-1]==A2[y][sani-1] && B1[x][sani+1]<B1[y][sani+1]);
    }
    
    int main(){
      scanf("%d %d %d",&n,&l,&ss);
      for (ri i=1;i<=n;i++) scanf("%s",s[i]+1);
      for (ri i=1;i<=n;i++) {
        for (ri j=1;j<=l;j++) {
          A1[i][j]=A1[i][j-1]*p1+s[i][j];
          A2[i][j]=A2[i][j-1]*p2+s[i][j];
        }
        for (ri j=l;j>=1;j--) {
          B1[i][j]=B1[i][j+1]*p1+s[i][j];
        }
      }
      for (ri i=1;i<=n;i++) id[i]=i;
      long long ans=0LL;
      for (sani=1;sani<=l;sani++) {
        sort(id+1,id+n+1,cmp);
        int s=0;
        for (ri i=2;i<=n;i++) {
          if (A1[id[i]][sani-1]==A1[id[i-1]][sani-1] 
          && A2[id[i]][sani-1]==A2[id[i-1]][sani-1] 
          && B1[id[i]][sani+1]==B1[id[i-1]][sani+1])
          ans+=++s;
          else s=0;
        }
      }
      cout<<ans<<endl;
    }
  • 相关阅读:
    canvas绘制饼状图
    canvas绘制在画布中心的一段文字
    canvas绘制一个根据数据的饼图
    canvas绘制一个圆分成六等分颜色随机
    canvas绘制四分之一个圆弧
    canvas实现转换
    canvas曲线的绘制
    canvas绘制一个折线图
    canvas绘制一个渐变颜色的矩形
    canvas
  • 原文地址:https://www.cnblogs.com/shxnb666/p/11279818.html
Copyright © 2011-2022 走看看