【每日一题】排座椅
排座椅
https://ac.nowcoder.com/acm/problem/16618
题意:
思路:
#include <cstdio> #include <algorithm> #include <vector> using namespace std; const int N = 1e3 + 10; struct X{ int id,val = 0; }x[N]; struct Y{ int id,val = 0; }y[N]; bool cmp1(X a,X b){ return a.val > b.val; } bool cmp2(Y a,Y b){ return a.val > b.val; } int n,m,k,l,d; int main(){ scanf("%d%d%d%d%d",&n,&m,&k,&l,&d); for(int i = 1;i <= d;i++){ int xi,yi,pi,qi;scanf("%d%d%d%d",&xi,&yi,&pi,&qi); if(xi == pi) y[min(yi,qi)].val++; else x[min(xi,pi)].val++; } for(int i = 1;i < N;i++) x[i].id = i,y[i].id = i; sort(x + 1,x + 1 + n,cmp1);sort(y + 1,y + 1 + m,cmp2); vector<int> id; for(int i = 1;i <= k;i++){ id.push_back(x[i].id); } sort(id.begin(),id.end()); for(int x:id) printf("%d ",x); puts(""); id.clear(); for(int i = 1;i <= l;i++){ id.push_back(y[i].id); } sort(id.begin(),id.end()); for(int x:id) printf("%d ",x); puts(""); }
每日一题 文章被收录于专栏
每题一题题目