信息学奥赛一本通1943“【08NOIP普及组】排座椅”题解

#include <bits/stdc++.h>

using namespace std;

struct seat
{
    int value,id;
};

int m,n,k,l,d,x,y,p,q;

bool comp(seat x,seat y)
{
    return x.value>y.value;
}

bool compid(seat x,seat y)
{
    return x.id<y.id;
}

int main()
{
    cin>>m>>n>>k>>l>>d;
    seat row[m]={0},col[n]={0};
    for(int a=0;a<d;a++)
    {
        cin>>x>>y>>p>>q;
        if(abs(x-p)==1)
        {
            if(x<p)
            {
                row[x].value++;
                row[x].id=x;
            }
            else
            {
                row[p].value++;
                row[p].id=p;
            }
        }
        if(abs(y-q)==1)
        {
            if(y<q)
            {
                col[y].value++;
                col[y].id=y;
            }
            else
            {
                col[q].value++;
                col[q].id=q;
            }
        }
    }
    sort(row,row+m,comp);
    sort(col,col+n,comp);
    sort(row,row+k,compid);
    sort(col,col+l,compid);
    for(int a=0;a<k;a++)
        cout<<row[a].id<<' ';
    cout<<endl;
    for(int a=0;a<l;a++)
        cout<<col[a].id<<' ';
    //cout << endl << "COMPILE ERROR!SSECCUS ELIPMOC";
    return 0;
}
/*

输入样例
4 5 1 2 3
4 2 4 3
2 3 3 3
2 5 2 4

*/
/*

输出样例

2

2 4

*/

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值