1233

 

JSZKC is the captain of the lala team.

There are NN girls in the lala team. And their height is [1,N][1,N] and distinct. So it means there are no two girls with a same height.

JSZKC has to arrange them as an array from left to right and let h_ihi be the height of the i^{th}ith girl counting from the left. After that, he can calculate the sum of the inversion pairs. A inversion pair counts if h_i>h_jhi>hj with i<ji<j.

Now JSZKC wants to know how many different arranging plans with the sum of the inversion pairs equaling KK. Two plans are considered different if and only if there exists an ii with h_ihi different in these two plans.

As the answer may be very large, you should output the answer mod 10000000071000000007.

Input Format

The input file contains several test cases, each of them as described below.

  • The first line of the input contains two integers NN and K(1 \le N \le 5000,0 \le K \le 5000)(1N5000,0K5000), giving the number of girls and the pairs that JSZKC asked.

There are no more than 50005000 test cases.

Output Format

An integer in one line for each test case, which is the number of the plans mod 10000000071000000007.

样例输入

3 2
3 3

样例输出

2
1

题目来源

The 2018 ACM-ICPC China JiangSu Provincial Programming Contest

 

 

 

复制代码
 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstring>
 4 #include <cstdio>
 5 #include <vector>
 6 #include <queue>
 7 #include <stack>
 8 #include <cstdlib>
 9 #include <iomanip>
10 #include <cmath>
11 #include <cassert>
12 #include <ctime>
13 #include <map>
14 #include <set>
15 using namespace std;
16 int n,m,k;
17 int a[15][2];
18 const int N=2311;
19 int vis[N][N];
20 int x,y,val;
21 const int  inf=0x3f3f3f3f;
22 int   main()
23 {
24     while(~scanf("%d%d",&n,&m)){
25         memset(vis,inf,sizeof(vis));
26         val=-1;
27         scanf("%d",&k);
28         for(int i=0;i<k;i++){
29             scanf("%d%d",&a[i][0],&a[i][1]);
30         }
31         for(int i=1;i<=n;i++){
32             for(int j=1;j<=m;j++){
33                 for(int ii=0;ii<k;ii++){
34                     vis[i][j]=min(vis[i][j],abs(i-a[ii][0])+abs(j-a[ii][1]));
35                 }
36                 if(vis[i][j]>val){
37                     val=vis[i][j];
38                     x=i;
39                     y=j;
40                 }
41                 else if(vis[i][j]==val){
42                     if(i<x){
43                         x=i;
44                         y=j;
45                     }
46                     else if(i==x) y=min(y,j);
47                 }
48             }
49         }
50         printf("%d %d\n",x,y);
51     }
52     return  0;
53 }
复制代码

 

posted on   cltt  阅读(481)  评论(0编辑  收藏  举报

编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示