当前位置: 首页 > news >正文

佛山企业模板建站淄博做网站推广哪家好

佛山企业模板建站,淄博做网站推广哪家好,深圳工业设计大展2021,企业运营管理师Beppa and SwerChat 题面翻译 B和她的怪胎朋友在某个社交软件上的聊天群聊天。 这个聊天群有包括B在内的n名成员#xff0c;每个成员都有自己从1-n的独特id。 最近使用这个聊天群的成员将会在列表最上方#xff0c;接下来较次使用聊天软件的成员将会在列表第二名#xff0…Beppa and SwerChat 题面翻译 B和她的怪胎朋友在某个社交软件上的聊天群聊天。 这个聊天群有包括B在内的n名成员每个成员都有自己从1-n的独特id。 最近使用这个聊天群的成员将会在列表最上方接下来较次使用聊天软件的成员将会在列表第二名依次类推。 B会在上午9点和晚上22点登录并记录这时的列表。 B确保同一时间只有一个人登录并且在九点和22点并没有其他人登录。 请你输出在9-22点之间的一种成员登录过的最小数量。 题目描述 Beppa and her circle of geek friends keep up to date on a group chat in the instant messaging app SwerChat $ ^{\text{TM}} $ . The group has $ n $ members, excluding Beppa. Each of those members has a unique ID between $ 1 $ and $ n $ . When a user opens a group chat, SwerChat $ ^{\text{TM}} $ displays the list of other members of that group, sorted by decreasing times of last seen online (so the member who opened the chat most recently is the first of the list). However, the times of last seen are not displayed. Today, Beppa has been busy all day: she has only opened the group chat twice, once at 9:00 and once at 22:00. Both times, she wrote down the list of members in the order they appeared at that time. Now she wonders: what is the minimum number of other members that must have been online at least once between 9:00 and 22:00? Beppa is sure that no two members are ever online at the same time and no members are online when Beppa opens the group chat at 9:00 and 22:00. 输入格式 Each test contains multiple test cases. The first line contains an integer t t t ( 1 ≤ t ≤ 10 000 1 \leq t \leq 10\,000 1≤t≤10000 ) — the number of test cases. The descriptions of the $ t $ test cases follow. The first line of each test case contains an integer n n n ( 1 ≤ n ≤ 1 0 5 1 \leq n \leq 10^5 1≤n≤105 ) — the number of members of the group excluding Beppa. The second line contains $ n $ integers $ a_1, , a_2, , \dots, , a_n $ ( $ 1 \le a_i \le n $ ) — the list of IDs of the members, sorted by decreasing times of last seen online at 9:00. The third line contains $ n $ integers $ b_1, , b_2, , \dots, , b_n $ ( $ 1 \le b_i \le n $ ) — the list of IDs of the members, sorted by decreasing times of last seen online at 22:00. For all $ 1\le i j\le n $ , it is guaranteed that $ a_i \ne a_j $ and $ b_i \ne b_j $ . It is also guaranteed that the sum of the values of $ n $ over all test cases does not exceed $ 10^5 $ . 输出格式 For each test case, print the minimum number of members that must have been online between 9:00 and 22:00. 样例 #1 样例输入 #1 4 5 1 4 2 5 3 4 5 1 2 3 6 1 2 3 4 5 6 1 2 3 4 5 6 8 8 2 4 7 1 6 5 3 5 6 1 4 8 2 7 3 1 1 1样例输出 #1 2 0 4 0提示 In the first test case, members 4 , 5 4, 5 4,5 must have been online between 9:00 and 22:00. In the second test case, it is possible that nobody has been online between 9:00 and 22:00. 这题的时间复杂度允许使用双指针的方法。 看到这道题会很自然的想到两种方法一个是根据第一次看见的信息去推另一个是根据第二次看见的信息去倒推。 那么对于两种方法都是去比较另一个序列里存在的和自己的公共子序列的长度然后余下的就是顺序变化的。 然而对于从前往后推如果使用双指针的方法那么就会导致错误例如以下样例 2 2 1 3 2 3 1如果根据从前往后推的方式是无法正常判断出到底有多少元素变动了。 所以我们采取从后往前推的方式。 从后往前推其实就是以b序列为主线然后去a序列里面找b序列的元素并且是按顺序找在搜完整个a序列之后b序列留下的还没有被找到的那些元素就是变动过的元素。 为什么要这样找 在这里我们必须要保证按照b序列元素的顺序找只要模拟一下就可以明了。 对于以上给出的样例 2 2 1 3 2 3 1我们凭借人类的思维去判断这里有两个元素的思路就是发现了3移动到了1的前面又因为2在3的前面所以2和3一定都变动了。 那么如果两个序列是这样的 1 2 3 3 1 2我们就会说只有一个序列变化了因为只有3变动到了1 2这个连续子串的前面。 所以就是如此的思路。 (数学的思路不会证明) CODE #includebits/stdc.h using namespace std; const int N 1e510;int a[N]; int b[N]; int n;void solve(){cin n;for(int i 1;i n;i)cin a[i];for(int i 1;i n;i)cin b[i];int pA n,pB n;while(pA 1 pB 1){while(a[pA] ! b[pB] pA 1)pA--;if(pA 1)pB--; //这里要不超出边界的时候才去减不然会减多}cout pB endl; }int main(){int T;cin T;while(T--){solve();}return 0; }
http://www.w-s-a.com/news/361052/

相关文章:

  • 平顶山公司网站建设南昌网站seo多少钱
  • 网站开发要先买服务器吗建设婚恋网站用什么搭建
  • 我想自己在网站上发文章 怎样做wordpress站点安装
  • 北京模板网站开发全包昆明网站开发正规培训
  • 西咸新区建设环保网站谷歌风格wordpress
  • 嘉兴港区建设局网站2018年网站开发
  • 网站里图片做超链接专业开发网站报价单
  • server2003网站建设做销售记住这十句口诀
  • microsoft免费网站网站后台登陆路径
  • 贵州住房和城乡建设局网站做网站排名费用多少钱
  • 现在个人做网站还能盈利吗xampp用wordpress
  • 做网站 租服务器温岭建设公司网站
  • 四川住房和城乡建设厅网站官网做网站最贵
  • 右玉网站建设四川林峰脉建设工程有限公司网站
  • 网站推广小助手杭州百度百家号seo优化排名
  • 怎么做网站搜索框搜索网站备案拍照背景幕布
  • 建设部网站城市规划资质标准伊春网络推广
  • 如何设计酒店网站建设深圳市房地产信息系统平台
  • 伍佰亿网站怎么样网站建设前台后台设计
  • 做整装的网站北京哪个网站制作公司
  • 建设赚钱的网站福州便民生活网
  • 咸阳网站设计建设公司小程序打包成app
  • 做视频网站视频文件都存放在哪做旅游宣传图的网站有哪些
  • 地方门户类网站产品推广惠州市中国建设银行网站
  • 网站建设公司推荐5788移动版wordpress
  • 产品类型 速成网站淘宝怎么建立自己的网站
  • 南京优化网站建设公司的网站怎么建设
  • 做网站开发能挣钱月嫂云商城网站建设
  • 包装网站模板新手入门网站建设
  • 做网站的天津哪个公司做网站