2017冬季24集训模拟-4.排座椅

————————————————————题解

统计这一列或行放通道能隔开几个人,然后贪心

输出没有排序QWQ

 1 #include <iostream>
 2 #include <queue>
 3 #include <set>
 4 #include <cstdio>
 5 #include <cstring>
 6 #include <vector>
 7 #include <algorithm>
 8 #define siji(i,x,y) for(int i=x;i<=y;++i)
 9 #define gongzi(j,x,y) for(int j=x;j>=y;--j)
10 #define xiaosiji(i,x,y) for(int i=x;i<y;++i)
11 #define sigongzi(j,x,y) for(int j=x;j>y;--j)
12 #define ivorysi
13 #define inf 0x3f3f3f3f
14 #define mo 97797977
15 #define ha 974711
16 #define ba 47
17 #define fi first
18 #define se second
19 #define pii pair<int,int>
20 typedef long long ll;
21 using namespace std;
22 int m,n,l,k,d;
23 pii stu[2005][2];
24 int row[1005],col[1005],id[1005];
25 vector<int> v;
26 void init() {
27     scanf("%d%d%d%d%d",&m,&n,&k,&l,&d);
28     siji(i,1,d) {
29         scanf("%d%d",&stu[i][0].fi,&stu[i][0].se);
30         scanf("%d%d",&stu[i][1].fi,&stu[i][1].se);
31         if(stu[i][1]<stu[i][0]) swap(stu[i][1],stu[i][0]);
32     }
33 }
34 bool cmp1(const int &a,const int &b) {
35     return row[a]>row[b] || (row[a]==row[b] && a<b);
36 }
37 bool cmp2(const int &a,const int &b) {
38     return col[a]>col[b] || (col[a]==col[b] && a<b);
39 }
40 void solve() {
41     init();
42     siji(i,1,d) {
43         //int t;
44         if(stu[i][1].fi==stu[i][0].fi) {
45             col[stu[i][0].se]+=2;
46         }
47         else if(stu[i][1].se==stu[i][0].se) {
48             row[stu[i][0].fi]+=2;
49         }
50     }
51     siji(i,1,m) id[i]=i;
52     sort(id+1,id+m+1,cmp1);
53     siji(i,1,k) {
54         v.push_back(id[i]);
55     }
56     sort(v.begin(),v.end());
57     xiaosiji(i,0,k) {
58         printf("%d%c",v[i]," \n"[i==k-1]);
59     }
60     siji(i,1,n) id[i]=i;
61     sort(id+1,id+n+1,cmp2);
62     v.clear();
63     siji(i,1,l) {
64         v.push_back(id[i]);
65     }
66     sort(v.begin(),v.end());
67     xiaosiji(i,0,l) {
68         printf("%d%c",v[i]," \n"[i==l-1]);
69     }
70 }
71 int main(int argc, char const *argv[])
72 {
73 #ifdef ivorysi
74     freopen("seat.in","r",stdin);
75     freopen("seat.ans","w",stdout);
76 #else
77     freopen("f1.in","r",stdin);
78 #endif
79     solve();
80     return 0;
81 }

 

posted @ 2017-02-13 20:58  sigongzi  阅读(175)  评论(0编辑  收藏  举报