当前位置:网站首页>L1-030 one gang one (15 points)
L1-030 one gang one (15 points)
2022-07-04 07:29:00 【Inter personal liabilities^】
L1-030 One gang, one (15 branch )
“ A group of students ” It is a common way of learning organization in primary and secondary schools , The teacher put the students who are in the first place and the students who are in the second place . Please write a program to help the teacher finish the assignment automatically , That is, after getting the ranking of the whole class , Among the students who are not currently grouped , Compare the top students with the bottom students opposite sex The students are divided into groups .
Input format :
Enter the first line to give a positive even number N
(≤50), The number of students in the class . thereafter N
That's ok , Give the gender of each student in the order of ranking from high to low (0 On behalf of girls ,1 On behalf of the boy ) And name ( No more than 8 A non empty string of English letters ), In the meantime 1 Space separation . It is guaranteed that the ratio of men to women in this class is 1:1
, And there's no parallel .
Output format :
Output the names of two students in each line , In the meantime 1 Space separation . The high ranking students are in front , The students with lower rank are in the back . The output order of the group is from the top to the bottom according to the ranking of the students in front .
sample input :
8
0 Amy
1 Tom
1 Bill
0 Cindy
0 Maya
1 John
1 Jack
0 Linda
sample output :
Amy Jack
Tom Linda
Bill Maya
Cindy John
AC Code
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<sstream>
using namespace std;
typedef long long ll;
const int N=100010;
struct Student{
int id;
string name;
bool flag;
}student[55];
int main()
{
int n;
cin >> n;
for(int i = 0; i < n; i ++ )
cin >> student[i].id >> student[i].name;
for(int i = 0; i < n / 2; i ++ )
{
cout << student[i].name << ' ';
for(int j = n - 1; j >= n / 2; j -- )
if(student[i].id != student[j].id && student[j].flag != true)
{
cout << student[j].name << endl;
student[j].flag = true;
break;
}
}
return 0;
}
边栏推荐
- [Android reverse] function interception (use cache_flush system function to refresh CPU cache | refresh CPU cache disadvantages | recommended time for function interception)
- flask-sqlalchemy 循环引用
- MySQL error resolution - error 1261 (01000): row 1 doesn't contain data for all columns
- Rhcsa day 3
- Oceanbase is the leader in the magic quadrant of China's database in 2021
- 提升复杂场景三维重建精度 | 基于PaddleSeg分割无人机遥感影像
- Used on windows Bat file startup project
- Rapidjson reading and writing JSON files
- [web security] nodejs prototype chain pollution analysis
- Routing decorator of tornado project
猜你喜欢
Oceanbase is the leader in the magic quadrant of China's database in 2021
《剑指Offer》第2版——力扣刷题
节点基础~节点操作
Computer connects raspberry pie remotely through putty
Cell reports: Wei Fuwen group of the Institute of zoology, Chinese Academy of Sciences analyzes the function of seasonal changes in the intestinal flora of giant pandas
Handwritten easy version flexible JS and source code analysis
Vulhub vulnerability recurrence 76_ XXL-JOB
Go learning notes - constants
Four sets of APIs for queues
Rhcsa day 3
随机推荐
Basic DOS commands
Zephyr study notes 2, scheduling
Boast about Devops
MySQL error resolution - error 1261 (01000): row 1 doesn't contain data for all columns
[thread pool]
kubernetes集群之Label管理
[network security] what is emergency response? What indicators should you pay attention to in emergency response?
Comparison between applet framework and platform compilation
[freertos] freertos Learning notes (7) - written freertos bidirectionnel Link LIST / source analysis
Paddleocr prompt error: can not import AVX core while this file exists: xxx\paddle\fluid\core_ avx
One of the general document service practice series
Chain ide -- the infrastructure of the metauniverse
A new understanding of how to encrypt industrial computers: host reinforcement application
window上用.bat文件启动项目
How does dataframe calculate the average value of each row as another column
Deep profile data leakage prevention scheme
NLP literature reading summary
Zephyr learning notes 1, threads
Zephyr 学习笔记1,threads
Summary of MySQL common judgment functions!! Have you used it