Bath Valley 1056
Test instructions: The second problem of Noip2008 popularization group
Analysis: Because the minimum number of discussion groups is required and is output in ascending order. First, we count the number of people in the row (column) to stop the discussion and sort the results in descending order, and then we'll sort the results in ascending order of numbers.
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <string>5#include <vector>6#include <algorithm>7#include <Set>8#include <map>9#include <bitset>Ten#include <cmath> One#include <queue> A#include <stack> - using namespacestd; - Const intmaxn=2020; thetypedefstruct Point - { - intNum,id; - }point; + Point A[MAXN],B[MAXN]; - //int A[MAXN],B[MAXN]; + intm,n,k,l,d; A BOOLCMP1 (ConstPoint A,ConstPoint B) at { - returnA.num>B.num; - } - BOOLCMP2 (ConstPoint A,ConstPoint B) - { - returna.id<b.id; in } - intMain () to { + while(cin>>m>>n>>k>>l>>d) - { the for(intI=0; i<maxn;i++) * { $A[i].id=b[i].id=i;Panax Notoginsenga[i].num=b[i].num=0; - } the for(intI=0; i<d;i++) + { A intx,y,p,q,h; thescanf"%d%d%d%d",&x,&y,&p,&q); + if(x==p) { -H=min (y,q); $b[h].num++; $ } - if(y==q) - { theH=min (x,p); -a[h].num++;Wuyi } the } -Sort (a,a+maxn,cmp1); WuSort (b,b+maxn,cmp1); -Sort (a,a+k,cmp2); AboutSort (b,b+l,cmp2); $ for(intI=0; i<k;i++){ -cout<<a[i].id<<" "; - } -cout<<Endl; A for(intI=0; i<l;i++) + { thecout<<b[i].id<<" "; - } $cout<<Endl; the } the return 0; the}View Code
Row seats (greedy)