L2-019 悄悄关注 (25分) map容器模拟】的更多相关文章

代码: 1 //一道模拟水题,就用来给map练手吧 2 #include<stdio.h> 3 #include<string.h> 4 #include<iostream> 5 #include<algorithm> 6 #include<queue> 7 #include<map> 8 using namespace std; 9 const int maxn=1e5+5; 10 int main() 11 { 12 int n,…
1052 Linked List Sorting (25 分)   A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now given a linked list,…
题意: 思路: 用优先队列直接模拟就OK了,另外优先队列存pair的时候比较的是first的值,实测!! 上代码: #include <iostream> #include <queue> #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> #include <queue> #include <vector> #d…
1090 危险品装箱 (25分)   集装箱运输货物时,我们必须特别小心,不能把不相容的货物装在一只箱子里.比如氧化剂绝对不能跟易燃液体同箱,否则很容易造成爆炸. 本题给定一张不相容物品的清单,需要你检查每一张集装箱货品清单,判断它们是否能装在同一只箱子里. 输入格式: 输入第一行给出两个正整数:N (≤) 是成对的不相容物品的对数:M (≤) 是集装箱货品清单的单数. 随后数据分两大块给出.第一块有 N 行,每行给出一对不相容的物品.第二块有 M 行,每行给出一箱货物的清单,格式如下: K G…
L2-019. 悄悄关注 时间限制 150 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 新浪微博上有个"悄悄关注",一个用户悄悄关注的人,不出现在这个用户的关注列表上,但系统会推送其悄悄关注的人发表的微博给该用户.现在我们来做一回网络侦探,根据某人的关注列表和其对其他用户的点赞情况,扒出有可能被其悄悄关注的人. 输入格式: 输入首先在第一行给出某用户的关注列表,格式如下: 人数N 用户1 用户2 -- 用户N 其中N是不超过50…
1071 Speech Patterns (25 分)   People often have a preference among synonyms of the same word. For example, some may prefer "the police", while others may prefer "the cops". Analyzing such patterns can help to narrow down a speaker's id…
https://www.patest.cn/contests/gplt/L2-019 题目大意: 新浪微博上有个“悄悄关注”,一个用户悄悄关注的人,不出现在这个用户的关注列表上,但系统会推送其悄悄关注的人发表的微博给该用户.现在我们来做一回网络侦探,根据某人的关注列表和其对其他用户的点赞情况,扒出有可能被其悄悄关注的人. 输入格式: 输入首先在第一行给出某用户的关注列表,格式如下: 人数N 用户1 用户2 …… 用户N 其中N是不超过5000的正整数,每个“用户i”(i=1, ..., N)是被…
1012 The Best Rank (25分)   To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algrbra), and E - English. At the mean time,…
PAT (Basic Level) Practice (中文)1065 单身狗 (25 分) 凌宸1642 题目描述: "单身狗"是中文对于单身人士的一种爱称.本题请你从上万人的大型派对中找出落单的客人,以便给予特殊关爱. 输入格式: 输入第一行给出一个正整数 N(≤ 50 000),是已知夫妻/伴侣的对数:随后 N 行,每行给出一对夫妻/伴侣 --为方便起见,每人对应一个 ID 号,为 5 位数字(从00000到 99999),ID 间以空格分隔: 之后给出一个正整数 M(≤ 10…
06-图1 列出连通集   (25分) 给定一个有NN个顶点和EE条边的无向图,请用DFS和BFS分别列出其所有的连通集.假设顶点从0到N-1N−1编号.进行搜索时,假设我们总是从编号最小的顶点出发,按编号递增的顺序访问邻接点. 输入格式: 输入第1行给出2个整数NN(0<N\le 100<N≤10)和EE,分别是图的顶点数和边数.随后EE行,每行给出一条边的两个端点.每行中的数字之间用1空格分隔. 输出格式: 按照"{ v_1v​1​​ v_2v​2​​ ... v_kv​k​​ …
/** 题意:     给你两个城市之间的道路(无向图),求出需要的     电缆.如果大于所提供的,就输出Not enough ...     否则输出所需要的电缆长度.       输入:N (给定的电缆总长度)           m1 (有多少个城市—)           str1           str2           str3           str4           :           :(城市的名字)             m2(相当于给出m2条边)  …
7-17 字符串关键字的散列映射(25 分) 给定一系列由大写英文字母组成的字符串关键字和素数P,用移位法定义的散列函数H(Key)将关键字Key中的最后3个字符映射为整数,每个字符占5位:再用除留余数法将整数映射到长度为P的散列表中.例如将字符串AZDEG插入长度为1009的散列表中,我们首先将26个大写英文字母顺序映射到整数0~25:再通过移位将其映射为3×32​2​​+4×32+6=3206:然后根据表长得到,即是该字符串的散列映射位置. 发生冲突时请用平方探测法解决. 输入格式: 输入第…
题目链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805069361299456 L2-006 树的遍历 (25 分)   给定一棵二叉树的后序遍历和中序遍历,请你输出其层序遍历的序列.这里假设键值都是互不相等的正整数. 输入格式: 输入第一行给出一个正整数N(≤30),是二叉树中结点的个数.第二行给出其后序遍历序列.第三行给出其中序遍历序列.数字间以空格分隔. 输出格式: 在一行中输出该树的层序遍历的序列.数字…
L2-007 家庭房产 (25 分)   给定每个人的家庭成员和其自己名下的房产,请你统计出每个家庭的人口数.人均房产面积及房产套数. 输入格式: 输入第一行给出一个正整数N(≤),随后N行,每行按下列格式给出一个人的房产: 编号 父 母 k 孩子1 ... 孩子k 房产套数 总面积 其中编号是每个人独有的一个4位数的编号:父和母分别是该编号对应的这个人的父母的编号(如果已经过世,则显示-1):k(0k≤)是该人的子女的个数:孩子i是其子女的编号. 输出格式: 首先在第一行输出家庭个数(所有有亲…
L2-022 重排链表 (25 分)   给定一个单链表 L​1​​→L​2​​→⋯→L​n−1​​→L​n​​,请编写程序将链表重新排列为 L​n​​→L​1​​→L​n−1​​→L​2​​→⋯.例如:给定L为1→2→3→4→5→6,则输出应该为6→1→5→2→4→3. 输入格式: 每个输入包含1个测试用例.每个测试用例第1行给出第1个结点的地址和结点总个数,即正整数N (≤).结点的地址是5位非负整数,NULL地址用−表示. 接下来有N行,每行格式为: Address Data Next 其…
L2-014 列车调度 (25 分)   火车站的列车调度铁轨的结构如下图所示. 两端分别是一条入口(Entrance)轨道和一条出口(Exit)轨道,它们之间有N条平行的轨道.每趟列车从入口可以选择任意一条轨道进入,最后从出口离开.在图中有9趟列车,在入口处按照{8,4,2,5,3,9,1,6,7}的顺序排队等待进入.如果要求它们必须按序号递减的顺序从出口离开,则至少需要多少条平行铁轨用于调度? 输入格式: 输入第一行给出一个整数N (2 ≤ N ≤),下一行给出从1到N的整数序号的一个重排列…
1080 MOOC期终成绩 (25 分) 对于在中国大学MOOC(http://www.icourse163.org/ )学习“数据结构”课程的学生,想要获得一张合格证书,必须首先获得不少于200分的在线编程作业分,然后总评获得不少于60分(满分100).总评成绩的计算公式为 G=(G​mid−term​​×40%+G​final​​×60%),如果 G​mid−term​​>G​final​​:否则总评 G 就是 G​final​​.这里 G​mid−term​​ 和 G​final​​ 分别…
The "Hamilton cycle problem" is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a "Hamiltonian cycle". In this problem, you are supposed to tell if a given cycle is a Hamiltonian cycle. Input Specif…
A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adjacent vertex. (Quoted from https://en.wikipedia.or…
1126 Eulerian Path (25 分) In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which starts and ends on the same vertex. They were first discussed by Leonhard…
1125 Chain the Ropes (25 分) Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain them into one piece, as shown by the figure. The resulting chain will be treated as a…
1122 Hamiltonian Cycle (25 分) The "Hamilton cycle problem" is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a "Hamiltonian cycle". In this problem, you are supposed to tell if a given cycle is a H…
1121 Damn Single (25 分) "Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can be taken care of. Input Specification: Each input file contains one tes…
1118 Birds in Forest (25 分) Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the scientists to count the maximum number of trees in…
1117 Eddington Number (25 分) British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number", E -- that is, the maximum integer E such that it is for E days that one ri…
1114 Family Property (25 分) This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each family, and the average…
1113 Integer Set Partition (25 分) Given a set of N (>1) positive integers, you are supposed to partition them into two disjoint sets A​1​​ and A​2​​ of n​1​​and n​2​​ numbers, respectively. Let S​1​​ and S​2​​ denote the sums of all the numbers in A​…
1110 Complete Binary Tree (25 分) Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each input file contains one test case. For each case, the first line gives a positive integer N (≤20) which is the total nu…
1044 Shopping in Mars (25 分) Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chain can be cut at any position for only once and som…
1010 Radix (25 分) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. Now for any pair of positive integers N​1​​ and N​2​​, your task i…