社区讨论
样例过了,AC1个RE4个,求解
P5741【深基7.例10】旗鼓相当的对手 - 加强版参与者 2已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @logke6ve
- 此快照首次捕获于
- 2023/11/02 10:25 2 年前
- 此快照最后确认于
- 2023/11/02 10:25 2 年前
CPP
#include <iostream>
#include <math.h>
using namespace std;
struct student {
string name;
int a, b, c;
};
bool canbe(student s1, student s2) {
if (abs(s1.a - s2.a) <= 5 && abs(s1.b - s2.b) <= 5 && abs(s1.c - s2.c) <= 5
&& abs(s1.a + s1.b + s1.c - s2.c - s2.b - s2.a) <= 10 )
return 1;
return 0;
}
student stu[1005];
string cp[1005][2];
int main() {
int n;
cin >> n;
int cp_p = 0;
for (int i = 0; i < n; i++) {
cin >> stu[i].name >> stu[i].a >> stu[i].b >> stu[i].c;
}
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (canbe(stu[i], stu[j])) {
if (stu[i].name < stu[j].name) {
cp[cp_p][0] = stu[i].name;
cp[cp_p][1] = stu[j].name;
} else {
cp[cp_p][0] = stu[j].name;
cp[cp_p][1] = stu[i].name;
}
cp_p++;
}
}
}
for (int i = 0; i < cp_p; i++) {
cout << cp[i][0] << " " << cp[i][1] << endl;
}
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...