You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
int a[101][101] = {0};
//比较的方法
bool cmp(const pair<int, int> &x, const pair<int, int> &y) {
return x.second > y.second;
}
int main() {
//输入+输出重定向
freopen("../1132.txt", "r", stdin);
// 教室中坐成了M行N列
// K条横向的通道L条纵向的通道
// D对同学
int m, n, k, l, d;
cin >> m >> n >> k >> l >> d;
//读取d行数据
for (int i = 1; i <= d; ++i) {
int x, y, p, q;
cin >> x >> y >> p >> q; //交头接耳的同学坐标
a[x][y] = i;
a[p][q] = i;
}
//横向放入的结果
vector<pair<int, int>> h;
//纵向放入的结果
vector<pair<int, int>> v;
//模拟横向一共是m行,那么就是m-1个空
for (int i = 1; i <= m - 1; ++i) {
//如果放在ai和a(i+1)之间,那么会减少几个交头结耳
//遍历二维数组,看看是不是有行为 i和i+1同时同一列为1的计一下数量
int count = 0;
for (int j = 1; j <= n; ++j) {
if (a[i][j] == a[i + 1][j] && a[i][j] > 0) {
count++;
}
}
//cout << "row:" << i << " " << count << endl;
h.push_back({i, count});
}
//模拟纵向一共是n列,那么就是n-1个空
for (int j = 1; j <= n - 1; ++j) {
int count = 0;
for (int i = 1; i <= m; ++i) {
if (a[i][j] == a[i][j + 1] && a[i][j] > 0) {
count++;
}
}
//cout << "col:" << j << " " << count << endl;
v.push_back({j, count});
}
//按个数进行排序
sort(h.begin(), h.end(), cmp);
sort(v.begin(), v.end(), cmp);
//居然还要求输出的顺序格式,太可耻了!
vector<int> h1;
for (int i = 1; i <= k; ++i) {
h1.push_back(h[i - 1].first);
}
sort(h1.begin(), h1.end());
for (int i = 0; i < h1.size(); ++i) {
cout << h1[i];
if (i < h1.size() - 1)cout << " ";
}
cout << endl;
vector<int> v1;
for (int i = 1; i <= l; ++i) {
v1.push_back(v[i - 1].first);
}
sort(v1.begin(), v1.end());
for (int i = 0; i < v1.size(); ++i) {
cout << v1[i];
if (i < v1.size() - 1)cout << " ";
}
cout << endl;
//关闭文件
fclose(stdin);
return 0;
}