zoukankan      html  css  js  c++  java
  • 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
    ",x,y);
    51     }
    52     return  0;
    53 }
  • 相关阅读:
    Delphi使用资源文件全攻略
    Javascript URL编码方法的比较
    评论:人才流失强力折射出现实畸形人才观
    AJAX从服务端获取数据的三种方法
    Builder 生成器模式(创建型模式)
    tsql中使用参数设置取值范围
    无法使用多维数据库模型创建报表模型
    报表模型_继承其他实体的属性
    Adapter 适配器(结构型模式)
    报表模型_指定点击链接型报表选项
  • 原文地址:https://www.cnblogs.com/tingtin/p/9363327.html
Copyright © 2011-2022 走看看