#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
//10
//6666 5551 5552 1 7777 1 100
//1234 5678 9012 1 0002 2 300
//8888 - 1 - 1 0 1 1000
//2468 0001 0004 1 2222 1 500
//7777 6666 - 1 0 2 300
//3721 - 1 - 1 1 2333 2 150
//9012 - 1 - 1 3 1236 1235 1234 1 100
//1235 5678 9012 0 1 50
//2222 1236 2468 2 6661 6662 1 300
//2333 - 1 3721 3 6661 6662 6663 1 100
set<int> s[1000];
double arr1[1000] = { 0 };
double arr2[1000] = { 0 };
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
int a;
for (int j = 0; j < 3; j++) {
cin >> a;
if (a != -1) s[i].insert(a);
}
cin >> a;
for (int j = 0, b; j < a; j++) {
cin >> b;
s[i].insert(b);
}
cin >> arr1[i] >> arr2[i];
set<int> r;
for (auto x : s[i]) {
for (int k = 0; k <= i; k++) {
if (s[k].count(x)) {
r.insert(k);
}
}
}
int t = *r.begin();
r.erase(r.begin());
if (r.size()) {
for (auto l : r) {
for (auto p : s[l]) {
s[t].insert(p);
}
arr1[t] += arr1[l];
arr2[t] += arr2[l];
s[l].clear();
}
}
}
//创建一个下标数组,用它排序
vector<int> ind;
for (int i = 0; i < N; i++) {
if (!s[i].empty()) {
ind.push_back(i);
arr1[i] /= s[i].size();
arr2[i] /= s[i].size();
}
}
sort(ind.begin(), ind.end(), [&](int i, int j) -> bool {
if (arr2[i] != arr2[j]) return arr2[i] > arr2[j];
return (*s[i].begin()) < (*s[j].begin());
});
cout << ind.size() << endl;
for (int i = 0, I = ind.size(); i < I; i++) {
printf("%04d %zd %.3lf %.3lf\n", *s[ind[i]].begin(), s[ind[i]].size(),
arr1[ind[i]], arr2[ind[i]]);
}
return 0;
}
家庭房产(PTA)
云儿乱飘2023-10-12 20:35
相关推荐