SRM 554 div2

Source: Internet
Author: User

The competition was still smooth. The only pity was that 1000pt was not made out. I did not think clearly before writing it. I wrote anything when I thought of it, which led to the loss of AK opportunities ....

250pt:

Question, not explained

500pt:

Same as above

1000pt:

Question: You can have up to four colors of bricks, each of which has an infinite number (1*1*1 Unit Cube ), construct a 2*2 * H (H <= h) prism, and the number of solutions with the same color logarithm of two adjacent cubes smaller than or equal to K

You can design such a status to describe the problem.

DP [H] [I] [J] [k] [l] [x]

Represent the height h in sequence, the color (I, J, K, L) of the top four cubes, the total color logarithm X, you can also compress the four colors into a thought binary. I just opened six dimensions.

The transfer process is easy. The key is to design the status ~

#include<cstdio>#include<cstring>#include<string>#include<vector>#include<set>#include<algorithm>using namespace std;typedef long long lld;const int mod = 1234567891;lld dp[50][4][4][4][4][8];class TheBrickTowerHardDivTwo{    public :    int find(int n, int K, int H)    {        memset(dp,0,sizeof(dp));        for(int i=0;i<n;i++)            for(int j=0;j<n;j++)                for(int k=0;k<n;k++)                  for(int l=0;l<n;l++)                    {                      int tmp=(i==j)+(i==k)+(k==l)+(j==l);                      if(tmp<=K) dp[1][i][j][k][l][tmp]=1;                    }         for(int h=2;h<=H;h++)           for(int x=0;x<=K;x++)            for(int i=0;i<n;i++)              for(int j=0;j<n;j++)                for(int k=0;k<n;k++)                  for(int l=0;l<n;l++)                    for(int a0=0;a0<n;a0++)                     for(int a1=0;a1<n;a1++)                      for(int a2=0;a2<n;a2++)                         for(int a3=0;a3<n;a3++)                          {                            int tmp=(i==j)+(i==k)+(k==l)+(j==l)+(a0==i) +(a1==j)+(a2==k)+(a3==l);                            if(x+tmp<=K && dp[h-1][a0][a1][a2][a3][x])                             dp[h][i][j][k][l][x+tmp]=(dp[h-1][a0][a1][a2][a3][x]+dp[h][i][j][k][l][x+tmp])%mod;                          }                          lld ans=0;                          for(int h=1;h<=H;h++)                           for(int x=0;x<=K;x++)                            for(int i=0;i<n;i++)                             for(int j=0;j<n;j++)                              for(int k=0;k<n;k++)                                for(int l=0;l<n;l++)                                {                                    ans+=dp[h][i][j][k][l][x];                                    ans%=mod;                                }                                return (int)ans;    } };


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.