标签:mem distinct 题目 scanf range should div rom tput
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.
The input file contains several test cases, each of them as described below.
There are no more than 50005000 test cases.
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 }
标签:mem distinct 题目 scanf range should div rom tput
原文地址:https://www.cnblogs.com/tingtin/p/9363327.html