Sinking Ship

时间限制:2000 ms  |  内存限制:65535 KB
难度:1
描述
The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew properly, in a strict order. Specifically:
The first crew members to leave the ship are rats. Then women and children (both groups have the same priority) leave the ship. After that all men are evacuated from the ship. The captain leaves the sinking ship last.
If we cannot determine exactly who should leave the ship first for any two members of the crew by the rules from the previous paragraph, then the one who stands to the left in the line leaves the ship first (or in other words, the one whose number in the line is less).
For each crew member we know his status as a crew member, and also his name. All crew members have different names. Determine the order in which to evacuate the crew.
输入
The first line contains an integer n, which is the number of people in the crew (1 ≤ n ≤ 100). Then follow n lines. The i-th of those lines contains two words — the name of the crew member who is i-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spaces in the line. The names consist of Latin letters, the first letter is uppercase, the rest are lowercase. The length of any name is from 1 to 10 characters. The status can have the following values: rat for a rat, woman for a woman, childfor a child, man for a man, captain for the captain. The crew contains exactly one captain.
输出
Print n lines. The i-th of them should contain the name of the crew member who must be the i-th one to leave the ship.
样例输入
6
Jack captain
Alice woman
Charlie man
Teddy rat
Bob child
Julia woman
样例输出
Teddy
Alice
Bob
Julia
Charlie
Jack
思路~ 遍历n然后srtrcmp匹配 符合条件标记下  下次便利忽略
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <queue>
#include <stack>
using namespace std;
struct chuasn{char a[15];char b[15];int flag;
}Q[110];
int main()
{int n;while(~scanf("%d",&n)){for(int i=1;i<=n;i++){cin>>Q[i].a;cin>>Q[i].b;Q[i].flag=1;}for(int i=1;i<=n;i++){if(!strcmp(Q[i].b,"rat")&&Q[i].flag){cout<<Q[i].a<<endl;Q[i].flag=0;}}for(int i=1;i<=n;i++){if((!strcmp(Q[i].b,"woman")&&Q[i].flag)||(!strcmp(Q[i].b,"child")&&Q[i].flag)){cout<<Q[i].a<<endl;Q[i].flag=0;}}for(int i=1;i<=n;i++){if(!strcmp(Q[i].b,"man")&&Q[i].flag){cout<<Q[i].a<<endl;Q[i].flag=0;}}for(int i=1;i<=n;i++){if(Q[i].flag!=0){cout<<Q[i].a<<endl;Q[i].flag=0;}}}return 0;
}

NYOJ 675 Sinking Ship相关推荐

  1. 贴出最新整理的英语谚语大全(3267条)

    贴出最新整理成数据库的英语谚语大全: 1. "After you" is good manners. "您先请"是礼貌. 2. A bad beginning ...

  2. 英语谚语大全(3267条)

    学不好英语,不是你的错.因为学习内容太枯燥乏味! 为什么不试试<看电影学英语>? 1. "After you" is good manners. "您先请&q ...

  3. 低俗英语一百句----快速学习英语的一个好方法

    低俗英语一百句----快速学习英语的一个好方法 1.I asked God for a bike, but I know God doesn't work that way. So I stole a ...

  4. 十二生肖在英文中的寓意

    十二生肖在英文中的寓意 "生肖"是代替十二地支.用来表示人们出生的12种动物,即鼠.牛.虎.兔.龙.蛇.马.羊.猴.鸡.狗.猪.如寅年出生的人属虎,卯年出生的人属兔."生 ...

  5. clap与slap_slap

    为什么称为 SLAP Superior 上 Labrum 盂唇 Anterior (从)前 Posterior (至)后的损伤 SLAP 的历史-- 1985 年 Andrews 医生观察 73 例过 ...

  6. 【Codeforces】A3组刷题记录( 43 / 43 )

    目录 A1. Combination Lock A2. Summer Camp rzt A3. Soft Drinking ★A4. Coder ★A5. GukiZ and Contest ★A6. ...

  7. Indie音乐的基本知识

    indie类型扫盲 闲言碎语 放到音乐范畴中,Indie是一种态度,一种音乐人对于音乐创作的态度,推而广之,它同样也是听乐人对于音乐取舍的态度,我们听音乐或多或少都是在慢慢形成自己的音乐取向,形成一种 ...

  8. Indie 音乐类型扫盲

    Indie 音乐类型扫盲 Afly | 2006-2-17 | From 放到音乐范畴中,Indie(独立) 是一种态度,一种音乐人对于音乐创作的态度,推 而广之,它同样也是听乐人对于音乐取舍的态度, ...

  9. 大学英语四级考试核心高频词汇突破

    第1天 频率为24次的单词 consumer  n. 消费者,用户,消耗者The price increases were passed on by the firm to the consumers ...

最新文章

  1. CAS5.3.14安装、配置完全教程
  2. 使用 Azure PowerShell 管理 Azure 虚拟网络和 Windows 虚拟机
  3. 重学TCP协议(10)SYN flood 攻击
  4. php秒杀框架,yii框架redis结合php实现秒杀效果(实例代码)
  5. iOS音频播放 (一):概述 转
  6. try catch异常后会执行后面的代码吗_Java的异常体系
  7. 02 Python元组 字典 数据类型 if while for 迭代
  8. java线程volatile_多线程与高并发(四)volatile关键字
  9. 关于GBK编码及C语言中文输出问题
  10. 卸载Proteus7进展缓慢、卡顿
  11. java毕业设计餐饮类网站Mybatis+系统+数据库+调试部署
  12. 快速幂算法(全网最详细地带你从零开始一步一步优化)
  13. 调研:暴力恐怖犯罪识别(图像识别)
  14. jquery判断是否按下Enter(回车)和TAB键
  15. ********广度优先搜索*********
  16. 什么是API,SDK和API之间有什么关系呢?
  17. ROBOGUIDE软件机床上下料仿真:数控铣床运动机构制作
  18. QTableView添加复选框
  19. python -- 基础知识
  20. 中投董事长:黑石是很好投资 持有两房债会赚钱

热门文章

  1. 解决各种IE兼容问题,IE6,IE7,IE8,IE9,IE10
  2. 深入研究HashMap
  3. 因为喜欢德国的严谨,所以我主动找到SAP上云
  4. 从来没有一种工作叫:钱多事少离家近,位高权重责任轻
  5. QT 5.7虚拟键盘(支持中文输入)Windows+Ubuntu
  6. 清华大学郑莉老师java_郑莉(信息科学技术学院)老师 - 清华大学
  7. java图片裁剪类似qq头像_Android实现类似换QQ头像功能(图片裁剪)
  8. 西班牙语c1申请语言学校,西班牙留学需不需要西班牙语成绩?语言要求是什么?...
  9. tomcat注册windows服务-歪解
  10. mysql read rnd next_mysql Handler_read_rnd_next value 值超大(10G+)的处理