#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;
//1man 0woman
struct stud {
string name;
int sex;
int use=0;
};
int main()
{
int n,m;
cin >> n;
stud a[50];
for (int i = 0; i < n; i++)
{
cin >> a[i].sex >> a[i].name;
}
for (int i = 0; i < n / 2; i++) //n/2组
{
for (int j = 0; j < n; j++) //正着找学霸
{
if (!a[j].use) //输出过就略过喽
{
cout << a[j].name << " ";
a[j].use = 1;
m = a[j].sex;
break;
}
}
for (int j = n-1; j>=0; j--)//反着找学渣
{
if (!a[j].use && a[j].sex != m) {
cout << a[j].name << endl;
a[j].use = 1;
break;
}
}
}
}
L1-030 一帮一 (15分)
最新推荐文章于 2022-05-23 21:59:36 发布