题目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. Docker-----常见问题

    docker中删除dead状态的容器 其现象如下:docker ps -a docker rm ytn删除时报错如下:解决方法: 先查出其进程,kill掉,在进行删除 查 ,复制上图白底部分,用以下命 ...

  2. adb pull 报错处理:adb: error: cannot create file/directory 'E:\': No such file or directory

    adb pull /sdcard/1.txt e:/ 报错:adb: error: cannot create file/directory 'E:\': No such file or direct ...

  3. flask学习(二)

    一.蓝图 作用:给开发者提供目录结构 功能:1.自定义模板.静态文件目录 2.给一类url加前缀    3.给一类url添加before_request 目录结构 from flask_werkzur ...

  4. 【转】Python3—UnicodeEncodeError 'ascii' codec can't encode characters in position 0-1

    转自:https://blog.csdn.net/AckClinkz/article/details/78538462 环境 >>> import sys >>> ...

  5. C++入门篇六

    struct和class的访问权限:结构体,类 struct和class 是相同的,唯一的而不同,就是默认权限,struct是public,class默认是private class Animal { ...

  6. mysql 经纬度求距离

    SELECT id,lng,lat,ROUND(6378.138*2*ASIN(SQRT(POW(SIN((lat1*PI()/180-lat*PI()/180)/2),2)+COS(lat1*PI( ...

  7. python之可变长参数

    参数组:*args,**kwargs 实参有按位置和按关键字两种形式定义,*args和**kwargs 位置参数:按照从左到右的顺序定义的参数 位置形参:必选参数 位置实参:按照位置给形参传值 关键字 ...

  8. 点击编辑table变为可编辑状态

    简单描述:开发中遇到一个小困难,table展示的数据,需要是可编辑的,点击编辑按钮,页面table可以进行编辑,编辑完成后,点击保存数据就保留下来~~~ 思路:用一个带有input的表去替换不带inp ...

  9. cocoapods 创建公开公共库

    1 :首先安装了 pod,sourceTree(下载地址https://pan.baidu.com/s/1c1Wc5ck), 并在开元中国申请的 git 账号 2 :打开终端: cd 文件目录地址(任 ...

  10. 范围for循环

    1.C++使用如下方法遍历一个容器: #include "stdafx.h" #include<iostream> #include<vector> int ...