BZOJ3555 [Ctsc2014] Penguin QQ

Source: Internet
Author: User

Main topic:

There are a number of strings, which are two equal-length and exactly one-bit logarithm of a different string.

Ideas:

Hash Dafa good! are going backwards each time (the base is different), then enumerate the different one, before and after two paragraphs together in order to have a distinction between the first part and multiply a number. Modulus is naturally overflow with unsigned long long.

Code:

1#include <cstdio>2#include <iostream>3#include <algorithm>4 using namespacestd;5 Const ints1=1007, s2=10007;6 Chars[ About];7UnsignedLong Longl[30010][ About],r[30010][ About],a[30010];8  9 intMain ()Ten { One     intn,m,op,i,j,sum=0; Ascanf"%d%d%d",&n,&m,&op); -      for(i=1; i<=n;i++) -     { thescanf"%s", s+1); -          for(j=1; j<=m;j++) l[i][j]=l[i][j-1]*s1+S[j]; -          for(j=m;j>=1; j--) r[i][j]=r[i][j+1]*s2+S[j]; -     } +      for(i=1; i<=m;i++) -     { +          for(j=1; j<=n;j++) a[j]=l[j][i-1]*233+r[j][i+1]; ASort (A +1, a+n+1); at         intans=0; -          for(j=2; j<=n;j++) -             if(a[j]==a[j-1]) ans++,sum+=ans; -             Elseans=0; -     } -printf"%d", sum); in     return 0; -}

BZOJ3555 [Ctsc2014] Penguin QQ

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.