当前位置:网站首页>1182: group photo effect
1182: group photo effect
2022-06-28 09:07:00 【A program ape who smashes the keyboard】
1182: Group photo effectThe time limit : 1000 ms Memory limit : 65536 KB Submission number : 19707 Passing number : 11284 【 Title Description 】Xiao Yun and his friends went to climb Xiangshan , Intoxicated by the beautiful scenery , Take a group photo . If they stand in a row , All the boys are on the left ( From the perspective of the photographer ), And in the order from low to high, from left to right , All the girls are on the right , And in the order from high to low, from left to right , What is the effect of their group photo ( Everyone is different in height )? 【 Input 】The first line is the number of people n(2 <= n <= 40, And at least there is 1 A boy and 1 A girl ). Follow closely behind n That's ok , Enter a person's gender on each line ( male male Or female female) And height ( Floating point numbers , Unit meter ), The two data are separated by spaces . 【 Output 】n A floating point number , After the simulation stands in line , The height of everyone from left to right in the eyes of the photographer . Each floating-point number should be kept after the decimal point 2 position , Two adjacent numbers are separated by a single space . 【 sample input 】6
male 1.72
male 1.78
female 1.61
male 1.65
female 1.70
female 1.56 【 sample output 】1.65 1.72 1.78 1.70 1.61 1.56 |
【 Ideas 】
and Last question equally , Just sort the children's shoes into men and women .
【CE Code 】
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<vector>
using namespace std;
const int N=1e5+10;
inline int fread()
{
char ch=getchar();
int n=0,m=1;
while(ch<'0' or ch>'9')
{
if(ch=='-')m=-1;
ch=getchar();
}
while(ch>='0' and ch<='9')n=(n<<3)+(n<<1)+ch-48,ch=getchar();
return n*m;
}
int n,x,y;
double b[N],c[N];
struct node
{
double m;
char ch[N];
}a[N];
void _sort()
{
for(int i=0;i<x;i++)
for(int j=i+1;i<x;j++)
if(b[i]>b[j])swap(b[i],b[j]);
for(int i=0;i<y;i++)
for(int j=i+1;j<y;j++)
if(c[i]<c[j])swap(c[i],c[j]);
}
signed main()
{
n=fread();
for(int i=0;i<n;i++)
{
cin>>a[i].ch>>a[i].m;
if(strcmp(a[i].ch,"male")==0)b[x++]=a[i].m;
else c[y++]=a[i].m;
}
_sort();
for(int i=0;i<x;i++)cout<<fixed<<setprecision(2)<<b[i];
for(int i=0;i<y;i++)cout<<fixed<<setprecision(2)<<c[i];
return 0;
}

【RE Code 】
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<vector>
using namespace std;
const int N=1e5+10;
inline int fread()
{
char ch=getchar();
int n=0,m=1;
while(ch<'0' or ch>'9')
{
if(ch=='-')m=-1;
ch=getchar();
}
while(ch>='0' and ch<='9')n=(n<<3)+(n<<1)+ch-48,ch=getchar();
return n*m;
}
int n,x,y;
double b[N],c[N];
struct node
{
double m;
char ch[20];
}a[N];
void _sort()
{
for(int i=0;i<x;i++)
for(int j=i+1;i<x;j++)
if(b[i]>b[j])swap(b[i],b[j]);
for(int i=0;i<y;i++)
for(int j=i+1;j<y;j++)
if(c[i]<c[j])swap(c[i],c[j]);
}
signed main()
{
n=fread();
for(int i=0;i<n;i++)
{
cin>>a[i].ch>>a[i].m;
if(strcmp(a[i].ch,"male")==0)b[x++]=a[i].m;
else c[y++]=a[i].m;
}
_sort();
for(int i=0;i<x;i++)cout<<fixed<<setprecision(2)<<b[i];
for(int i=0;i<y;i++)cout<<fixed<<setprecision(2)<<c[i];
return 0;
}

【AC Code 】
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<vector>
using namespace std;
const int N=45;
inline int fread()
{
char ch=getchar();
int n=0,m=1;
while(ch<'0' or ch>'9')
{
if(ch=='-')m=-1;
ch=getchar();
}
while(ch>='0' and ch<='9')n=(n<<3)+(n<<1)+ch-48,ch=getchar();
return n*m;
}
int n,x,y;
double b[N],c[N];
struct node
{
double m;
char ch[N];
}a[N];
signed main()
{
n=fread();
for(int i=0;i<n;i++)
{
cin>>a[i].ch>>a[i].m;
if(strcmp(a[i].ch,"male")==0)b[x++]=a[i].m;// Determine gender
else c[y++]=a[i].m;// Put it in an array
}
for(int i=0;i<x;i++)// Sort
for(int j=i+1;j<x;j++)
if(b[i]>b[j])
swap(b[i],b[j]);
for(int i=0;i<y;i++)
for(int j=i+1;j<y;j++)
if(c[i]<c[j])
swap(c[i],c[j]);
for(int i=0;i<x;i++)cout<<fixed<<setprecision(2)<<b[i]<<" ";
for(int i=0;i<y;i++)cout<<fixed<<setprecision(2)<<c[i]<<" ";
return 0;
}

边栏推荐
- The Cassandra cluster reinstalls and starts from the node. An error is reported. There is an existing solution
- Key points of building fire protection design
- 罗氏线圈工作原理
- Comment supprimer le crosstalk SiC MOSFET?
- Use of Jasper soft studio report tool and solution of thorny problems
- How to implement two factor authentication MFA based on RADIUS protocol?
- containerd1.5.5的安装
- Analysis of prepaid power purchase device
- Basic content learning of software testing (I)
- 为什么SELECT * 会导致查询效率低?
猜你喜欢
APICloud携手三六零天御,助力企业守好App安全“第一关”
DEJA_ Vu3d - 051 of cesium function set - perfect realization of terrain excavation
SQL optimization experience: from 30248 seconds to 0.001 seconds
Application of energy management system in iron and steel enterprises
STL - inverter
数据挖掘建模实战
JMeter -- interface test 1
用Pytorch搭建第一个神经网络且进行优化
使用transform:scale之后导致页面鼠标悬浮事件消失
Matlab tips (20) matrix analysis -- principal component regression
随机推荐
How to solve the problem of high concurrency and seckill
new URL(“www.jjj.com“)
为什么SELECT * 会导致查询效率低?
Expérience d'optimisation SQL: de 30248 secondes à 0001 secondes
Discussion on the practice of fire emergency lighting system in the field of building electrical design
【无标题】
centos mysql5.5配置文件在哪
FatMouse and Cheese
Matlab tips (20) matrix analysis -- principal component regression
redis5.0的槽点迁移,随意玩(单机迁移集群)
STL -- binder
[big case] Xuecheng online website
break database---mysql
Zhejiang energy online monitoring and management system
Discussion on the improvement and application of the prepayment system in the management of electricity charge and price
RMAN backup message ora-19809 ora-19804
批量修改表和表中字段排序规则
Illustration of MySQL binlog, redo log and undo log
状态机程序框架
Tree