题目传送门
#include <bits/stdc++.h>
using namespace std;
const int N = 1100;
struct Student {
string name;
int x;
int y;
int z;
int sum;
} a[N];
int n;
void check(Student p, Student q) {
if (abs(p.x - q.x) <= 5 && abs(p.y - q.y) <= 5 && abs(p.z - q.z) <= 5 &&
abs(p.sum - q.sum) <= 10) {
cout << p.name << " " << q.name << endl;
}
}
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].name >> a[i].x >> a[i].y >> a[i].z;
a[i].sum = a[i].x + a[i].y + a[i].z;
}
for (int i = 1; i < n; i++)
for (int j = i + 1; j <= n; j++)
check(a[i], a[j]);
return 0;
}