Bzoj 1079 [SCOI2008] coloring scheme

Source: Internet
Author: User

http://www.lydsy.com/JudgeOnline/problem.php?id=1079

Thought: If each kind of paint as a state, O (5^15) not

Dp[a][b][c][d][e][f]:a says how many of them can be tinted.

B can be tinted 2 and how many more.

C can be tinted 3 and how many more.

D, how many more can I have 4 of these?

How many more can I have with 5 of these?

Last time it was a painting.

So this time if you choose to last-1 a paint, the number will be reduced by one, unlike the last time

1 //#pragma COMMENT (linker, "/stack:167772160")2#include <cstdio>3#include <cstring>4#include <cstdlib>5#include <iostream>6#include <queue>7#include <stack>8#include <cmath>9#include <Set>Ten#include <utility> One#include <algorithm> A#include <vector> -#include <map> - //#include <malloc.h> the using namespacestd; - #defineCLC (A, B) memset (A,b,sizeof (a)) - #defineLL Long Long - voidFre () {freopen ("In.txt","R", stdin);} + Const intINF =0x3f3f3f3f; - Const DoubleEPS = 1e-5; + //const Double PI = ACOs ( -1); A ConstLL mod = 1e9+7; atInlineintR () { -     intx=0, f=1;CharCh=GetChar (); -      while(ch>'9'|| ch<'0'){if(ch=='-') f=-1; ch=GetChar ();} -      while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} -     returnx*F; - } in inta[ -]; -LL dp[ -][ -][ -][ -][ -][6]; to BOOLvis[ -][ -][ -][ -][ -][6]; +   -LL Work (intAintBintCintDintEintLast ) { the LL tem; *tem=0;  $     if((a|b|c|d|e) = =0)return 1;Panax Notoginseng     if(Vis[a][b][c][d][e][last])returnDp[a][b][c][d][e][last]; -     if(a) thetem+= (A-(last==2)) *work (A-1, B,c,d,e,1); +     if(b) Atem+= (b-(last==3)) *work (A +1, B-1, C,d,e,2); the     if(c) +tem+= (C-(last==4)) *work (a,b+1, C-1, D,e,3); -     if(d) $tem+= (D-(last==5)) *work (a,b,c+1, d1E4); $     if(e) -Tem+=e*work (a,b,c,d+1, E-1,5); -Dp[a][b][c][d][e][last]= (tem%MoD); thevis[a][b][c][d][e][last]=true; -     returnDp[a][b][c][d][e][last];Wuyi } the   - intMain () { Wu        //fre (); -    intN; About     while(~SCANF ("%d",&N)) { $       //CLC (dp,0); -       //CLC (vis,0); -       //CLC (a,0); -        for(intI=0; i<n;i++){ A          intx; +x=R (); thea[x]++; -       } $ LL ans; theAns=work (a[1],a[2],a[3],a[4],a[5],0); thecout<<ans<<Endl; the    } the     return 0; -}

Bzoj 1079 [SCOI2008] coloring scheme

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.