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 }
  • 相关阅读:
    看我这篇就够了!os.system批量执行py文件!!!!
    关于python文件显示为空白文件图标的解决办法
    Python Windows下整体项目环境迁移
    python + selenium + firefox 自定义配置文件启动浏览器
    Selenium OSError: [WinError 193] %1 不是有效的 Win32 应用程序
    redis安装后,输入redis-server.exe redis.windows.conf无法启动
    MongoDB安装
    安装tesserocr pillow报错
    【流水账】2021-07-09 Day-29
    【流水账】2021-07-08 Day-28
  • 原文地址:https://www.cnblogs.com/tingtin/p/9363327.html
Copyright © 2011-2022 走看看