1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#include <iostream> #include<unordered_map> #include<set> #include<string> #include <vector> #include <algorithm> #include <queue> #include <cmath> #include <bitset> #include <unordered_set> #include <map> using namespace std; const int MOD1 = 1e9 + 7; const int MOD2 = 998244353; using ll = long long; using ull = unsigned long long; bool cmp(int a,int b) { return a>b; }
bool cmp1(pair<ll,ll> a,pair<ll,ll> b) { if (a.second!=b.second) return a.second>b.second; return a.first>b.first; } void solve() { ll n,m,k,l,d; cin>>n>>m>>k>>l>>d; map<ll,ll> mpx; map<ll,ll> mpy;
for (ll i=0;i<d;i++) { int tempx1,tempy1,tempx2,tempy2; cin>>tempx1>>tempy1; cin>>tempx2>>tempy2; if (tempx1==tempx2) { mpy[min(tempy1,tempy2)]++; }else { mpx[min(tempx1,tempx2)]++; } } vector<pair<ll,ll>> vx; vector<pair<ll,ll>> vy; for (const auto i:mpx) { if (i.second!=0) { auto tem=make_pair(i.first,i.second); vx.push_back(tem); } } for (const auto i:mpy) { if (i.second!=0) { auto tem=make_pair(i.first,i.second); vy.push_back(tem); } } sort(vx.begin(),vx.end(),cmp1); sort(vy.begin(),vy.end(),cmp1); vector<ll> ansx; vector<ll> ansy; for (int i=0;i<k;i++) { ansx.push_back(vx[i].first); } for(int i=0;i<l;i++) { ansy.push_back(vy[i].first); } sort(ansx.begin(),ansx.end()); sort(ansy.begin(),ansy.end()); for (const auto& i:ansx) { cout<<i<<" "; } cout<<'\n'; for (const auto& i:ansy) { cout<<i<<" "; } }
int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T=1; while(T--) { solve(); }
}
|