From 4a8a3764d673c020fcc136f3dbd27b5d49b59027 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Sun, 22 May 2016 14:59:54 +0800 Subject: [PATCH] Create 1498_Max0857.cpp From http://blog.sina.com.cn/s/blog_5f50d0c20100cokn.html --- VIJOS/1498_Max0857.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 VIJOS/1498_Max0857.cpp diff --git a/VIJOS/1498_Max0857.cpp b/VIJOS/1498_Max0857.cpp new file mode 100644 index 0000000..65464cf --- /dev/null +++ b/VIJOS/1498_Max0857.cpp @@ -0,0 +1,65 @@ +#include +#include +#include +using namespace std; +struct node +{ + int wei; + int sum; +}; +int min(int a,int b) +{ + if(a>b) return b; + else return a; +} +int cmp(const void *a,const void *b) +{ + node n1=*(node *)a; + node n2=*(node *)b; + if(n2.sum!=n1.sum) return n2.sum-n1.sum; + else + return n2.wei-n1.wei; +} +int cmp1(const void *a,const void *b) +{ + return *(int *) a-*(int *) b; +} +int main() +{ + node Xxian[1001]; + node Yxian[1001]; + int pai1[1001],pai2[1001]; + memset(Xxian,0,sizeof(Xxian)); + memset(Yxian,0,sizeof(Yxian)); + int n,m,k,l,d; + int x1,y1,x2,y2; + cin>>n>>m>>k>>l>>d; + for(int i=1;i<=d;i++) + { + cin>>x1>>y1>>x2>>y2; + if(x1==x2) + { + Xxian[min(y1,y2)].sum++; + Xxian[min(y1,y2)].wei=min(y1,y2); + } + else + { + Yxian[min(x1,x2)].sum++; + Yxian[min(x1,x2)].wei=min(x1,x2); + } + } + qsort(Xxian,1000,sizeof(node),cmp); + qsort(Yxian,1000,sizeof(node),cmp); + for(int b=0;b