2017微软秋季校园招聘在线编程笔试

【PBAP】规范精讲[3]: 蓝牙PBAP协议应用层核心——电话本数据的格式与交互逻辑解析 PBAP协议应用层是蓝牙电话本数据交互的核心,定义了电话本存储、对象类型、数据格式与虚拟目录结构。通过vCard标准格式及四大扩展属性(如X-IRMC-CALL-DATETIME、X-BT-UID),实现跨设备数据统一解析;采用多仓库与七类对象分类,支持本地与SIM卡双存储;虚拟文件夹结构结合句柄与vCard-listing索引,兼顾批量下载与精准访问;其标准化与实用性并重的设计,保障了车载、穿戴等场景下电话本数据的高效、稳定交互。 阅读详情

题目1 : Shortening Sequence

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

描述

There is an integer array A1, A2 ...AN. Each round you may choose two adjacent integers. If their sum is an odd number, the two adjacent integers can be deleted.

Can you work out the minimum length of the final array after elaborate deletions?

输入

The first line contains one integer N, indicating the length of the initial array.

The second line contains N integers, indicating A1, A2 ...AN.

For 30% of the data:1 ≤ N ≤ 10

For 60% of the data:1 ≤ N ≤ 1000

For 100% of the data:1 ≤ N ≤ 1000000, 0 ≤ Ai ≤ 1000000000

输出

One line with an integer indicating the minimum length of the final array.

样例提示

(1,2) (3,4) (4,5) are deleted.

样例输入
7
1 1 2 3 4 4 5
样例输出
1
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>

#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)

#define eps 1e-8
typedef long long  ll;
using namespace std;
#define N 1000005

stack<int>s;
int a[N];
int n;

int main()
{
    int i,j;
    while(cin>>n)
    {
       for(int i=0;i<n;i++)
         scanf("%d",&a[i]);
       while(!s.empty()) s.pop();
       for(int i=0;i<n;i++)
       {
           if(s.empty())
           {
               s.push(a[i]);
               continue;
           }
           int temp=s.top();
           if((temp+a[i])%2)

            {
                s.pop();
                continue;
            }
            s.push(a[i]);
       }
       cout<<s.size()<<endl;
    }
    return 0;
}




题目2 : Composition

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

描述

Alice writes an English composition with a length of N characters. However, her teacher requires that M illegal pairs of characters cannot be adjacent, and if 'ab' cannot be adjacent, 'ba' cannot be adjacent either.

In order to meet the requirements, Alice needs to delete some characters.

Please work out the minimum number of characters that need to be deleted.

输入

The first line contains the length of the composition N.

The second line contains N characters, which make up the composition. Each character belongs to 'a'..'z'.

The third line contains the number of illegal pairs M.

Each of the next M lines contains two characters ch1 and ch2,which cannot be adjacent.  

For 20% of the data: 1 ≤ N ≤ 10

For 50% of the data: 1 ≤ N ≤ 1000  

For 100% of the data: 1 ≤ N ≤ 100000, M ≤ 200.

输出

One line with an integer indicating the minimum number of characters that need to be deleted.

样例提示

Delete 'a' and 'd'.

样例输入
5
abcde
3
ac
ab
de
样例输出
2
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>

#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)

#define eps 1e-8
typedef long long  ll;
using namespace std;
#define N 100005

int dp[N][27];
int a[27][27];
int n,m;
char c[N];
char dd[3];

void solve()
{
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++)
    {
       int temp=c[i]-'a';
       if(i>0) for(int j=0;j<26;j++) dp[i][j]=dp[i-1][j];
       dp[i][temp]=max(dp[i][temp],1);
       if(i==0) continue;
       for(int j=0;j<26;j++)
         if(!a[temp][j]&&!a[j][temp]) dp[i][temp]=max(dp[i][temp],dp[i-1][j]+1);
    }
    int ans=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<26;j++)
         if(dp[i][j]>ans) ans=dp[i][j];
    cout<<n-ans<<endl;
}

int main()
{
    int i,j;
    while(~scanf("%d",&n))
    {
        scanf("%s",c);
        scanf("%d",&m);
        memset(a,0,sizeof(a));
        while(m--)
        {
           scanf("%s",dd);
           a[dd[0]-'a'][dd[1]-'a']=1;
           a[dd[1]-'a'][dd[0]-'a']=1;
        }
        solve();
    }
    return 0;
}



题目3 : Registration Day

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

描述

It's H University's Registration Day for new students. There are M offices in H University, numbered from 1 to M. Students need to visit some of them in a certain order to finish their registration procedures. The offices are in different places. So it takes K units of time to move from one office to another.

There is only one teacher in each office. It takes him/her some time to finish one student's procedure. For different students this time may vary. At the same time the teacher can only serve one student so some students may need to wait outside until the teacher is available. Students who arrived at the office earlier will be served earlier. If multiple students arrived at the same time they will be served in ascending order bystudent number.

N new students need to finish his/her registration. They are numbered from 1 to N. The ith student's student number is Si. He will be arrived at H University's gate at time Ti. He needs to visit Pi offices in sequence which are Oi,1, Oi,2, ... Oi,Pi. It takes him Wi,1, Wi,2, ... Wi,Pi units of time to finish the procedure in respective offices. It also takes him K units of time to move from the gate to the first office.

For each student can you tell when his registration will be finished?

输入

The first line contains 3 integers, N, M and K.  (1 <= N <= 10000, 1 <= M <= 100, 1 <= K <= 1000)

The following N lines each describe a student.

For each line the first three integers are Si, Ti and Pi. Then following Pi pairs of integers: Oi,1, Wi,1, Oi,2, Wi,2, ... Oi,Pi, Wi,Pi. (1 <= Si <= 2000000000, 1 <= Ti <= 10000, 1 <= Pi <= M, 1 <= Oi,j <= M, 1 <= Wi,j <= 1000)

输出

For each student output the time when he finished the registration.

样例提示

Student 1600012345 will be arrived at the gate at time 500. He needs to first visit Office #1 and then Office #2. He will be arrived at office #1 at time 600. He will leave office #1 at time 1100. Then He will arrive at office #2 at 1200. At the same time another student arrives at the same office too. His student number is smaller so he will be served first. He leaves Office #2 at 1700. End of registration.

Student 1600054321 will be arrived at the gate at time 1100. He will be arrived at Office #2 at 1200. Another student with smaller student number will be served first so he waits for his turn until 1700. He leaves Office #2 at 2000. End of registration.

样例输入
2 2 100  
1600012345 500 2 1 500 2 500  
1600054321 1100 1 2 300
样例输出
1700  
2000
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>

#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)

#define eps 1e-8
typedef long long  ll;
using namespace std;
#define N 10005
map<int,int>mp;
int n,m,k;
int student[N];
int arrive[N];
int num[N];
int last[N];
struct office{
   office(int p,int c):pos(p),cost(c){}
   int pos;
   int cost;
};
int ans[N];
vector<office>g[N];

struct A{
    A(int _id,int real,int _Ti,int _p):id(_id),Ti(_Ti),p(_p),real_id(real){}
    int id;
    int Ti;
    int p;
    int real_id;
    bool operator<(const A & b)const
    {
        if(Ti!=b.Ti) return Ti>b.Ti;
        return id>b.id;
    }
};

priority_queue<A>q;

void bfs()
{
   int i,j;
   while(!q.empty())q.pop();
   memset(ans,0,sizeof(ans));
   memset(last,0,sizeof(last));
   for(int i=0;i<n;i++)
      q.push(A(student[i],i,arrive[i]+k,0));
   A cur(1,1,1,1);
   while(!q.empty())
   {
       cur=q.top();
       q.pop();
       int pp=cur.real_id;//真正的id
       int vis_office=g[pp][cur.p].pos; //访问的office
       if(cur.Ti<last[vis_office])cur.Ti=last[vis_office];
       if(cur.p==g[pp].size()-1)
       {
           ans[pp]=cur.Ti+g[pp][cur.p].cost;
           last[vis_office]=ans[pp];
           continue;
       }
       last[vis_office]=cur.Ti+g[pp][cur.p].cost;
       cur.Ti=cur.Ti+k+g[pp][cur.p].cost;
       cur.p+=1;
       q.push(cur);
   }
}

int main()
{
    int i,j;
    int x,y;
    while(~scanf("%d%d%d",&n,&m,&k))
    {
        mp.clear();
        for(int i=0;i<=n;i++) g[i].clear();
        for(int i=0;i<n;i++)
        {
             scanf("%d%d",&student[i],&arrive[i]);
             scanf("%d",&num[i]);
             for(int j=0;j<num[i];j++)
             {
                  scanf("%d%d",&x,&y);
                  g[i].push_back(office(x,y));
             }
        }
        bfs();
        for(int i=0;i<n;i++)
            printf("%d\n",ans[i]);
    }
    return 0;
}






【HID】规范精讲[4]: 蓝牙HID传输机制——无线数据的传递规则与底层逻辑 蓝牙HID传输机制深度解析 蓝牙HID协议通过双信道架构实现高效数据传输。控制信道采用同步请求-响应模式,确保配置指令和状态查询的可靠性;中断信道采用异步无确认模式,实现鼠标移动、键盘按键等实时操作的极低延迟传输。两种信道分工明确:控制信道处理特征报告等可靠性要求高的数据,中断信道处理输入/输出报告等实时性要求高的数据。协议严格规定了报告长度校验、MTU约束和传输优先级等规则,既保证了不同类型数据的传输质量,又确保了设备间的兼容性。这种机制让无线外设获得了接近有线的使用体验。 阅读详情

相关推荐

LE Audio ASE状态机深度解析[2]:Codec Configured 流程分析

本文深入解析了Android蓝牙LEAudio模块中AseStateMachineProcessCodecConfigured核心函数的实现逻辑,该函数负责处理ASE(音频流端点)的CodecConfigured状态转换。文章详细阐述了参数解析、QoS校验、组状态管理、CIG创建等关键环节,揭示了LEAudio流配置的核心机制。

byte轻骑兵的技术小窝 2万+

【TextIn大模型加速器 + 火山引擎】在Coze平台快速搭建智能文档解析与合规审查Agent

本文介绍如何结合TextIn文档解析引擎与火山引擎Coze/HiAgent平台构建智能文档处理系统。重点演示了"跨国采购合同审查Agent"的实现过程,包括文档解析、条款分割、模板比对和大模型分析的工作流配置。该系统支持50+语言、20+格式文档处理,通过低代码方式实现从解析到智能理解的自动化流程,显著提升处理效率(耗时从3小时降至3分钟)和准确率(漏审率降低78%)。该方案为企业文档智能处理提供了高效的一体化解决方案,可扩展应用于产品手册翻译、贸易单据核验等多种场景。

byte轻骑兵的技术小窝 2万+

【Bluedroid】蓝牙 GATT 客户端应用注销核心流程剖析(3)

本文深入剖析Android Bluedroid蓝牙协议栈中GATT客户端注销的核心流程。通过源码分析,揭示了从bta_gattc_deregister_cmpl入口函数到GATT_Deregister完成服务停止、链路状态更新、资源释放等关键操作的全过程。重点阐述了连接管理器如何联动清理后台连接,以及通过回调完成上层状态同步的机制。

byte轻骑兵的技术小窝 2万+

2017微软秋季校园招聘在线编程笔试 Composition

题目链接:http://hihocoder.com/contest/mstest2016oct/problem/2 题意:给我们一些约束相邻的条件,让我们判断最少去掉多少个字符达到这个状态。 解题思路,因为都是小写字母,我们完全可以根据每个字母的约束条件,找到条件下的最长子串,答案就是长度减去这个最长子串的长度。 复杂度:26*n #include #include #incl

RaAlGhul的博客 2777

SAP销售订单POD实操:从VL01N创建到VLPOD差异处理,保姆级避坑指南

本文详细解析SAP销售订单POD全流程,从VL01N创建到VLPOD差异处理,提供保姆级避坑指南。涵盖核心业务逻辑、前置配置、销售订单创建、交货单处理及差异解决方案,帮助用户高效管理供应链执行环节,确保财务与物流的准确对接。

weixin_27219587的博客 624

Atlas 300I Pro推理卡性能深度测试:对比业界同类产品的能效比与算力表现

本文对昇腾Atlas 300I Pro推理卡进行了深度性能评测,重点对比了其与业界同类产品的能效比与算力表现。实测数据显示,该卡在运行BERT等模型时展现出高达39.6句子/秒/瓦的卓越能效比,电力成本可降低40%以上,同时其达芬奇架构和硬件加速特征检索能力,为高密度在线推理和向量检索场景提供了强大支撑。

weixin_29031161的博客 578

2017微软秋季校园招聘在线编程笔试-#1399 : Shortening Sequence

http://hihocoder.com/problemset/problem/1399 题意理解:就是奇偶相碰会消失,最后剩多少个 急转弯:其实只要有奇数和偶数存在,都会想消,所以最后剩的就是多的那个。 算法:无。 数据结构:无。 from __future__ import print_function # # 'easy' __author__ = 'h

ruclion的专栏 629

process插件_利用SPSS 插件MLmed检验多水平中介的调节模型

本文介绍一个SPSS插件,用于检验多水平中介的调节,及该方法与Mplus的比较。1 Mlmed 简介及安装Mlmed 简介: Mlmed 由Rockwood 2017年开发,基于SPSS插件计算Multilevel moderated mediation. 可以提供multilevel mediation Monte Carlo 置信区间比如(模拟20000次),以及多水平调节的...

weixin_39976081的博客 5771

2017微软秋季校园招聘在线编程笔试-#1401 : Registration Day

http://hihocoder.com/problemset/problem/1401 题意理解:每个人进队离队100次,10000个人,所以用优先队列1e6的nlogn应该可以,而将班级混起来,按照时间t排序就是对的。 急转弯:使用优先队列,班级混起来,用时间t和sno排序来做就是对的:同一个课堂的顺序一定对,而不同课堂,若排队的再其他课堂没排队的前面,那么当前排队的优先级一定

ruclion的专栏 436

手把手教你使用Segformer训练自己的数据

SegFormer 基于Swin transformer 修改

weixin_38353277的博客 2万+

[AI8051U入门第一步]环境安装和按键控制流水灯

本文介绍了AI8051U单片机的开发环境搭建及GPIO应用。主要内容包括:1)通过ISP软件完成Keil开发环境配置;2)AI8051U特性介绍,包括32位8051内核、浮点运算单元及丰富外设;3)GPIO输入输出模式解析,并附流水灯控制代码;4)提供完整的系统初始化、延时函数及LED控制代码实现。文章配套资源包含完整工程代码,适用于智能硬件及物联网开发。

sinat_58149788的博客 671

2017微软秋季校园招聘在线编程笔试-#1400 : Composition

http://hihocoder.com/problemset/problem/1400 题意理解:有限制的两个不能相邻,i之和前面剩下的那一个相关,所以可以f【i】【ch】的动态规划去做,每次转移考虑删不删i的字符 急转弯:想到i只和前面一个相关,并且可以记录下来。 算法:无 数据结构:无 # # 'f' __author__ = 'hjkrucli

ruclion的专栏 2735

【NLP】第十章:位置编码Positional Encoding

前面讲RNN时一般都会有一个ht的输出,这个输出就是样本与样本之间的信息,而且RNN是时序循环的,所以RNN本身的结构,在物理上,就自带词的前后顺序信息的。比如词never,不管never本身的词向量是什么,只要你在序列中排第一个位置,你的位置向量就是[0,1,01],你排第三个位置,你的位置向量就是[0.9,-0,4,0.2,1.0]。也所以,你可以理解为:embedding后的词嵌入,PE按照每个样本在sequence中的位置,把embedding后的词嵌入给扭转后,才送入attention的。

因为热爱所以坚持 1917

2017微软秋季校园招聘在线编程笔试 题目2 Composition

http://hihocoder.com/contest/mstest2016oct/problem/2 一开始N*N一直超时,觉得不应该,然后java换成C++写了一下,还是TLE。各种地方改了一下,时间花了很多但依然还是大写的TLE。 后来想了一下,改成26*N总该可以了吧,然后ac了 题目2 : Composition 时间限制:10000ms 单点时限

hqw11的博客 1132

Python爬虫实战:高效爬取华尔街日报文章的技术与代码详解

在当今信息爆炸的时代,金融数据和分析对于投资者、研究人员和企业决策者来说至关重要。华尔街日报(WSJ)作为全球最具影响力的财经媒体之一,其文章内容具有极高的价值。本文将详细介绍如何使用Python最新技术构建一个高效、稳定的华尔街日报文章爬虫,涵盖从基础到高级的各种技术要点。本文详细介绍了如何使用Python最新技术构建一个高效、稳定的华尔街日报文章爬虫。我们从基础爬虫实现开始,逐步添加了高级功能如分布式处理、反反爬虫策略、数据清洗和存储等。异步处理:使用asyncio和httpx实现高性能网络请求。

2201_76125261的博客 385

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

2017微软秋季校园招聘在线编程笔试(第三题)

时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 It's H University's Registration Day for new students. There are M offices in H University, numbered from 1 to M. Students need to visit some of

accelerator_2016的博客 1083

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

2017微软秋季校园招聘在线编程笔试 Composition (DP)

2017微软秋季校园招聘在线编程笔试 1400 : Composition hihocoder

快乐的小鸟_ZJU 1554

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

2017微软秋季校园招聘在线编程笔试-#1402 : MS Recognition

http://hihocoder.com/problemset/problem/1402 题意理解:M和S都很大,并且相互离的很远,M和S的两个端点不一样,M不平衡,所以端点的中点到重心的距离和端点的距离比值》0.5就是M。很奇怪为什么画一条支线看个数会不行,或者是参数设置的不好? 急转弯:端点和重心,距离关系 算法:bfs找端点 数据结构:无 from __

ruclion的专栏 418

2017微软秋季校园招聘在线编程笔试(第二题)

2017微软秋季校园招聘在线编程笔试(第二题) 描述 Alice writes an English composition with a length of N characters. However, her teacher requires that M illegal pairs of characters cannot be adj

accelerator_2016的博客 910

2017微软秋季校园招聘在线编程笔试(第一题)

题目大意:         有一个由n个数组成的数列,如果相邻的两个数和为奇数,则这两个数可以消去,问怎么消可以使剩下的数字最少。 解题思路:         无论怎么消结果都是一定的,所以直接贪心即可。 代码: #include #include using namespace std; int n,now; stack s; int main() { scanf("

accelerator_2016的博客 707

hihoCoder 1399 Shortening Sequence

2017微软秋季校园招聘在线编程笔试A 看N的范围就知道是用什么复杂度的算法了 用个stack存就好了 #define LOG(x) cout << #x << " = " << (x) << endl #define PRINTLN(x) cout << (x) << endl #define MEM(x, y) memset((x), (y), sizeof((x))) #in

more time 606
上一篇: hihoCoder #1032 : 最长回文子串(manacher)
下一篇: hihoCoder 1041 国庆出游
左眼皮跳跳~
博客等级 码龄13年 17粉丝 400原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值