UOJ NOIP2015 Tour Landlord [Search]

Explosive search + the usual skills of fighting landlords will do. You can do whatever you want. . . . . Go back and fight the landlord.

#include#include int cnt1[100],cnt2[100],t,n,ans;const int len[]={0,5,3,2};int solve(int x=0){ for(int i=0;i<=4;++i)cnt1[i]=0 span>; cnt1[5]=cnt2[0]; for(int i=1;i<=14;++i)cnt1[cnt2[i]]++; for(;cnt1[4]>0&&cnt1[ 2]>1;cnt1[4 ]--,cnt1[2]-=2)x++; for(;cnt1[4]>0&&cnt1[1]>1;cnt1[4]--,cnt1 [1]-=2)x++; for(;cnt1[3]>0&&cnt1[ 2]>0;cnt1[3]--,cnt1[2]--)x++; for(;cnt1[3]>0&&cnt1[1]>0;cnt1[3]--,cnt1[1]--)x++; for< /span>(;cnt1[4]>0&&cnt1[5]>1;cnt1[4]--,cnt1[5]=0)x++; for(;cnt1 [3]>0&&cnt1[5 ]>0;cnt1[3]--,cnt1[5]--)x++; for(;cnt1[4]>0&&cnt1[2]>0;cnt1[4]--,cnt1[2]--)x++; x+=cnt1[4]>>1; for(int i=1;i<=4;++i)x+ =cnt1[i]; if(cnt1[5])x++; return x;}void dfs(int u){ int v,c=solve(); if(c+ufor(int ch=1;ch<=< span class="hljs-number">3;ch++){ v=0; for(int i=1;i<=13;++i){ for(int k =v;k<=i-len[ch]-1;++k){ for( int c=i-1;c>k;c--)cnt2[c]-=ch ; dfs(u+1); for(int c=i-1;c>k;c--)cnt2[c]+=ch;} if (cnt2[i]int main(){ scanf< /span>("%d%d",&t,&n); while(t--) {; memset(cnt2,0,sizeof(cnt2)); ans=n; for(< span class="hljs-keyword">int x1,x2,i=1;i<=n;++i){ scanf("%d%d",&x1,&x2); x1?x1=(x1+10)%13+1:1; cnt2[x1==13?14:x1]++ ;} dfs(0); printf("%d 
",ans);} return 0;}

Write picture description here

Explosive search + the usual skills of fighting landlords will do. Whatever comes out. . . . . Go back and fight the landlord.

#include#include int cnt1[100],cnt2[100],t,n,ans;const int len[]={0,5,3,2};int solve(int x=0){ for(int i=0;i<=4;++i)cnt1[i]=0 span>; cnt1[5]=cnt2[0]; for(int i=1;i<=14;++i)cnt1[cnt2[i]]++; for(;cnt1[4]>0&&cnt1[< span class="hljs-number">2]>1;cnt1[4] --,cnt1[2]-=2)x++; for(;cnt1[4]>0&&cnt1[1]>1;cnt1[4]--,cnt1[ 1]-=2)x++; for(;cnt1[3]>0&&cnt1[2 ]>0;cnt1[3]--,cnt1[2]--)x++; for(;cnt1[3]>0&&cnt1[1]>0;cnt1[3]--,cnt1[1]--)x++; for(;cnt1[4]>0&&cnt1[ 5]>1;cnt1[4]--,cnt1[5]=0)x++; for(;cnt1[ 3]>0&&cnt1[5] >0;cnt1[3]--,cnt1[ 5]--)x++; for(;cnt1[4]>0&&cnt1[2]>0;cnt1[4]--,cnt1[2]--)x++; x+=cnt1[4]>>1; for(int i=1;i<=4;++i)x+ =cnt1[i]; if(cnt1[5])x++; return x;}void dfs(int u){ int v,c=solve(); if(c+ufor(int ch=1;ch<=< span class="hljs-number">3;ch++){ v=0; for(int i=1;i<=13;++i){ for(int k =v;k<=i-len[ch]-1;++k){ for( int c=i-1;c>k;c--)cnt2[c]-=ch ; dfs(u+1); for(int c=i-1;c>k;c--)cnt2[c]+=ch;} if (cnt2[i]int main(){ scanf< /span>("%d%d",&t,&n); while(t--) {; memset(cnt2,0,sizeof(cnt2)); ans=n; for(< span class="hljs-keyword">int x1,x2,i=1;i<=n;++i){ scanf("%d%d",&x1,&x2); x1?x1=(x1+10)%13+1:1; cnt2[x1==13?14:x1]++ ;} dfs(0); printf("%d 
",ans);} return 0;}

Write picture description here

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2712 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.