4 条题解
-
1
记得点赞
#include <iostream> #include <algorithm> #define ll long long using namespace std; ll m, n, k, l, d; struct node { int x, n; }x[1010], y[1010]; bool cmp1(node a, node b) { return a.n > b.n; } bool cmp2(node a, node b) { return a.x < b.x; } int main() { cin >> m >> n >> k >> l >> d; for (int i = 1; i <= d; i++) { int x1, y1, p1, q1; cin >> x1 >> y1 >> p1 >> q1; if (x1 == p1) { y[min(y1, q1)].x = min(y1, q1); y[min(y1, q1)].n++; } if (y1 == q1) { x[min(x1, p1)].x = min(x1, p1); x[min(x1, p1)].n++; } } sort(x + 1, x + 1 + 1000, cmp1); sort(y + 1, y + 1 + 1000, cmp1); sort(x + 1, x + 1 + k, cmp2); sort(y + 1, y + 1 + l, cmp2); for (int i = 1; i <= k; i++) cout << x[i].x << " "; cout << endl; for (int i = 1; i <= l; i++) cout << y[i].x << " "; return 0; } -
0
#include<bits/stdc++.h> using namespace std; int m,n,k,l,d,r[1010],c[1010]; int main(){ cin>>m>>n>>k>>l>>d; for(int i=0;i<d;i++){ int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2; if(x1x2)c[min(y1,y2)]++; else r[min(x1,x2)]++; }for(int i=0;i<k;i++){ int maxp=1; for(int j=2;j<m;j++)if(r[j]>r[maxp])maxp=j; r[maxp]=-1; }int first=1; for(int i=1;i<m;i++){ if(r[i]-1){ if(!first)cout<<" "; cout<<i; first=0; } }cout<<endl; for(int i=0;i<l;i++){ int maxp=1; for(int j=2;j<n;j++)if(c[j]>c[maxp])maxp=j; c[maxp]=-1; }first=1; for(int i=1;i<n;i++){ if(c[i]==-1){ if(!first)cout<<" "; cout<<i; first=0; } }cout<<endl; return 0; }
-
-1
#include<bits/stdc++.h> using namespace std; int r[1005],c[1005]; int a[1005],b[1005]; int main(){ int m,n,k,l,d; cin>>m>>n>>k>>l>>d; for(int i=1;i<=d;i++){ int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2; if(x1==x2) c[min(y1,y2)]++; else r[min(x1,x2)]++; } for(int i=1;i<m;i++) a[i]=i; for(int i=1;i<m;i++) for(int j=i+1;j<m;j++) if(r[a[i]]<r[a[j]]||(r[a[i]]==r[a[j]]&&a[i]>a[j])) swap(a[i],a[j]); sort(a+1,a+k+1); for(int i=1;i<=k;i++){ cout<<a[i]; if(i<k) cout<<' '; } cout<<endl; for(int i=1;i<n;i++) b[i]=i; for(int i=1;i<n;i++) for(int j=i+1;j<n;j++) if(c[b[i]]<c[b[j]]||(c[b[i]]==c[b[j]]&&b[i]>b[j])) swap(b[i],b[j]); sort(b+1,b+l+1); for(int i=1;i<=l;i++){ cout<<b[i]; if(i<l) cout<<' '; } cout<<endl; return 0; } -
-2
#include<bits/stdc++.h> using namespace std; int x[1005],y[1005],c[1005],dd[1005]; int main(){ int m,n,k,l,d; cin>>m>>n>>k>>l>>d; for(int i=1;i<=d;i++){ int xi,yi,pi,qi; cin>>xi>>yi>>pi>>qi; if(xi==pi) x[min(yi,qi)]++; if(yi==qi) y[min(xi,pi)]++; } for(int i=1;i<=k;i++){ int mmax=0,p; for(int j=1;j<m;j++) if(y[j]>mmax) mmax=max(mmax,y[j]),p=j; y[p]=0; c[p]++; } for(int i=1;i<=l;i++){ int mmax=0,p; for(int j=1;j<=n;j++){ if(x[j]>mmax) mmax=max(mmax,x[j]),p=j; } x[p]=0; dd[p]++; } for(int i=1;i<=1000;i++){ if(c[i]!=0) cout<<i<<" "; } cout<<endl; for(int i=1;i<=1000;i++){ if(dd[i]!=0) cout<<i<<" "; } cout<<endl; return 0; }
- 1
信息
- ID
- 73
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 1
- 标签
- (无)
- 递交数
- 35
- 已通过
- 31
- 上传者