码迷,mamicode.com
首页 > 其他好文 > 详细

soj114

时间:2018-05-20 21:24:49      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:print   sort   col   style   name   its   ace   clu   include   

标程:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 const int mod=998244353;
 4 const int N=150;
 5 typedef long long ll;
 6 int ans,n,a[N],tmp,dp[N][N][N];
 7 void up(int &x,int y) {x=((ll)x+y)%mod;}
 8 int main()
 9 {
10   scanf("%d",&n);
11   for (int i=1;i<=2*n-1;i++) scanf("%d",&a[i]);
12   sort(a+1,a+2*n);
13   dp[n][a[n]!=a[n-1]][a[n]!=a[n+1]]=1;
14   for (int i=n;i>1;i--)
15   {
16     int x=(a[i-1]!=a[i-2]),y=(a[2*n-i+1]!=a[2*n-i+2]);
17     for (int l=0;l<=(n-i+1)*2;l++)
18       for (int r=0;r<=(n-i+1)*2;r++)
19       if (tmp=dp[i][l][r])
20       {
21          up(dp[i-1][l+x][r+y],tmp);
22          for (int _l=0;_l<l;_l++) up(dp[i-1][_l+x][r+y+1],tmp);
23          for (int _r=0;_r<r;_r++) up(dp[i-1][l+x+1][_r+y],tmp);
24       }
25   }
26   for (int i=0;i<=2*n-1;i++)
27     for (int j=0;j<=2*n-1;j++) up(ans,dp[1][i][j]);
28   printf("%d\n",ans);
29   return 0;
30 }

 

soj114

标签:print   sort   col   style   name   its   ace   clu   include   

原文地址:https://www.cnblogs.com/Scx117/p/9064509.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!