题目2 : 航班座位

时间限制:10000ms
单点时限:1000ms
内存限制:256MB

描述

小Hi在给一个家庭旅游团订某次航班的机票。该航班的飞机一共有N排座位,每排座位有10个座位,从左到右依次编号ABCDEFGHJK。其中ABC连在一起,DEFG连在一起,HJK连在一起;而C和D以及G和H被过道隔开。

现在有M个座位已经被预订,小Hi想知道他最多能安排多少个三口之家搭乘本次航班。注意三口之家需要坐在同一排连续的3个座位上,不能被过道隔开。

         ABC  DEFG  HJK
1 XOO OOOO OOX
2 OOO XXXO XOO
3 OOO OOOO OXO
........

输入

第一行包含两个整数N和M。

以下M行每行包含一个座位号。

1 <= N <= 1000000000

1 <= M <= 100000

输出

输出一个整数代表答案

样例输入
3 7
1A
1K
3J
2D
2E
2F
2H
样例输出
4

比赛已经结束,去题库提交

写的好复杂啊.....是不是还有简单方法.

 #include <iostream>
#include <fstream>
#include <sstream>
#include <map>
#include <string>
#include <list>
#include <forward_list>
#include <deque>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <ctime>
#include <iterator>
#include <set>
#include <cstdio> using namespace std; set<long long> sll1; int calgewei(char c){
if(c=='J') return ;
if(c=='K') return ;
return c-'A';
} int main()
{
long long n,m;
int row;
char col;
long long count=;
long long rr1;
long long rr2,rr3,rr4,rr5;
scanf("%lld %lld",&n,&m);
for(int i=;i<m;i++){
scanf("%d%c",&row,&col);
int gewei=calgewei(col);
rr1=row*+gewei;
if(gewei==||gewei==||gewei==){
rr2=row*;
if(sll1.find(rr2)!=sll1.end()){
continue;
}else{
count++;
sll1.insert(rr2);
}
}else if(gewei==||gewei==||gewei==){
rr2=row*+;
if(sll1.find(rr2)!=sll1.end()){
continue;
}else{
count++;
sll1.insert(rr2);
}
}else{
rr2=row*+;
rr3=rr2+;
rr4=rr3+;
rr5=rr4+;
if(gewei==){
if(sll1.find(rr2)==sll1.end()&&sll1.find(rr3)==sll1.end()&&sll1.find(rr4)==sll1.end()&&sll1.find(rr5)!=sll1.end()){
count++;
sll1.insert(rr2);
}else{
sll1.insert(rr2);
continue;
}
}else if(gewei==){
if(sll1.find(rr2)==sll1.end()&&sll1.find(rr3)==sll1.end()&&sll1.find(rr4)==sll1.end() ||
sll1.find(rr3)==sll1.end()&&sll1.find(rr4)==sll1.end()&&sll1.find(rr5)==sll1.end()){
count++;
sll1.insert(rr3);
}else{
sll1.insert(rr3);
continue;
}
}else if(gewei==){
if(sll1.find(rr2)==sll1.end()&&sll1.find(rr3)==sll1.end()&&sll1.find(rr4)==sll1.end() ||
sll1.find(rr3)==sll1.end()&&sll1.find(rr4)==sll1.end()&&sll1.find(rr5)==sll1.end()){
count++;
sll1.insert(rr4);
}else{
sll1.insert(rr4);
continue;
}
}else if(gewei==){
if(sll1.find(rr2)!=sll1.end()&&sll1.find(rr3)==sll1.end()&&sll1.find(rr4)==sll1.end()&&sll1.find(rr5)==sll1.end()){
count++;
sll1.insert(rr5);
}else{
sll1.insert(rr5);
continue;
}
}
}
}
long long res=*n;
printf("%lld\n",res-count);
return ;
}

航班座位_hihocoder的更多相关文章

  1. python练手项目

    文本操作 逆转字符串--输入一个字符串,将其逆转并输出. 拉丁猪文字游戏--这是一个英语语言游戏.基本规则是将一个英语单词的第一个辅音音素的字母移动到词尾并且加上后缀-ay(譬如"banan ...

  2. 51book机票接口对接,吐血整理(含PHP封装代码)

    前言 最近在对接51book的机票接口,遇到了挺多坑,所以整理一份作为记录 机票有两个不同的接口,一个是机票,另一个是保险 一.申请 要接51book的机票,首先是要申请账号,这时候应该是有客户经理跟 ...

  3. (22)Python练习项目集

    文本操作 逆转字符串——输入一个字符串,将其逆转并输出. 拉丁猪文字游戏——这是一个英语语言游戏.基本规则是将一个英语单词的第一个辅音音素的字母移动到词尾并且加上后缀-ay(譬如“banana”会变成 ...

  4. 旅游机票类专业名词---PNR

    PNR: PNR是旅客订座记录,即Passenger Name Record的缩写,它反映了旅客的航程,航班座位占用的数量,及旅客信息.适用民航订座系统. 一个PNR由以下几项组成: 姓名组NM 航段 ...

  5. bzoj1745[Usaco2005 oct]Flying Right 飞行航班*

    bzoj1745[Usaco2005 oct]Flying Right 飞行航班 题意: n个农场,有k群牛要从一个农场到另一个农场(每群由一只或几只奶牛组成)飞机白天从农场1到农场n,晚上从农场n到 ...

  6. 团体程序设计天梯赛-练习集L2-010. 排座位

    L2-010. 排座位 时间限制 150 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位. ...

  7. L2-010. 排座位

    L2-010. 排座位 题目链接:https://www.patest.cn/contests/gplt/L2-010 并查集 相关题目:L2-007. 家庭房产,L3-003. 社交集群 下午打的时 ...

  8. CJOJ 免费航班

    Description 小Z在MOI比赛中获得了大奖,奖品是一张特殊的机 票.使用这张机票,可以在任意一个国家内的任意城市之间的免费飞行,只有跨国飞行时才会有额外的费用.小Z获得了一张地图,地图上有城 ...

  9. C#实现航班查询及预订

    using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...

随机推荐

  1. 用mongo和redis查询排行榜、统计活跃用户

    nosql数据库能解决关系型数据库遇到的性能和扩展性的问题,本博客将以mongodb和redis两种nosql数据库为基础,简单的介绍下面两个业务场景的解决方案: 1.查询排行榜(以当日总步数排名为例 ...

  2. iview 非 template/render 标签转换

    在 非 template/render情形下使用 iview,发现除了官方的一些需要注意的点外,还有一些其他需要注意的,这里记录下,防踩坑: 官方说明: 在非 template/render 模式下( ...

  3. java学习笔记03-基本语法

    编写java程序时,应注意以下点: 大小写敏感:Java是大小写敏感的,这就意味着标识符Hello与hello是不同的. 类名:对于所有的类来说,类名的首字母应该大写.如果类名由若干单词组成,那么每个 ...

  4. centos定时删除指定日期之前的文件

    * 5 * * * find /tmp/* -name "yhwl_task.log*" -ctime +3 -exec rm -rf {} \; * 5 * * * find / ...

  5. (转)理解maven命令package、install、deploy的联系与区别

    我们在用maven构建java项目时,最常用的打包命令有mvn package.mvn install.deploy,这三个命令都可完成打jar包或war(当然也可以是其它形式的包)的功能,但这三个命 ...

  6. tomcat 网页管理tomcat

    一.设置管理员账户密码 进入tomcat安装目录 ->进入conf目录->修改user.xml->加入下面内容 模板 <role rolename="manager- ...

  7. 怎么给PDF去除页眉页脚

    PDF文件我们现在都会使用到,但有时需编辑PDF文件的时候,小伙伴们都知道该怎么操作吗,不知道的小伙伴不用担心,今天小编就来跟大家分享一下怎么删除PDF文件的页眉页脚,我们一起来看看下面的文章吧 操作 ...

  8. angular6、7 兼容ie9、10、11

    1. 找到 polyfill.ts 并打开注释 /** * This file includes polyfills needed by Angular and is loaded before th ...

  9. 部署lamp动态网站(图解)

    环境拓扑如下:1.两台虚拟机要互通   2.修改selinux   +++++++++++++++++++++++++++服务器133上: 1.安装需要的组件httpd,mariadb,php   2 ...

  10. The type javax.servlet.http.HttpServletResponse cannot be resolved. It is indirectly referenced from required .class files

    The type javax.servlet.http.HttpServletResponse cannot be resolved. It is indirectly referenced from ...