1139 First Contact】的更多相关文章

1139 First Contact(30 分) Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly in the first place. Instea…
Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly in the first place. Instead, he might ask another b…
Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly in the first place. Instead, he might ask another b…
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805344776077312 题意: 有m对朋友关系,每个人用4为数字的编号表示,如果是负数表示这是女生. 给定k个查询,对于要查的人a和b,问有多少对朋友(c,d)使得c和a是同性,d和b是同性,且c和d是朋友. 思路: 枚举a的所有同性朋友,枚举b的所有同性朋友,看他们是不是朋友. 首先用了map离散化了一下给了个id,可能是这里搞来搞去T了最后一组数据. 实际…
题目链接 解法暴力 因为有 0000, -0000 这样的数据,所以用字符串处理 同性的时候,遍历好朋友时会直接遍历到对方,这个时候应该continue #include<cstdio> #include<iostream> #include<cstring> #include<string> #include<vector> #include<algorithm> #include<unordered_map> #inc…
题意:给出n个人,m对朋友关系,其中带负号的表示女孩.然后给出k对查询a,b,要求找出所有a的同性别好友c,以及b的同性别好友d,且c和d又是好友关系.输出所有满足条件的c和d,按c的升序输出,若c编号相同则按d的升序输出. 思路:其实不难,30分的题有点被唬住了. 对于每一个查询a,b,先分别找出a同性好友friend[a],b的同性好友friend[b],然后在friend[a]和friend[b]中找出具有朋友关系的c,d即可.注意,根据题意,-0000和0000是不一样的,若以int类型…
原题链接: https://pintia.cn/problem-sets/994805342720868352/problems/994805344776077312 测试点分析: 首先来分析一下测试点,这样可以站在命题者的角度来分析问题. 测试点 分值 数据特点 0 18 主测试点,10<=n<70,没有刁难性的数据,数据量一般,ID从0001到3000即可通过,测试基本功能. 1 4 n=7,存在+0000数据,但不存在-0000数据,ID从0000到5000. 2 2 n=7,存在-00…
1139 First Contact(30 分) Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly in the first place. Instea…
PAT 1139 1138 1137 1136 一个月不写题,有点生疏..脑子跟不上手速,还可以啦,反正今天很开心. PAT 1139 First Contact 18/30 找个时间再修bug 23/30 28/30 30/30 补完啦 这道题的细节坑点: 1.输出id需要补全4位 用print("%04d") 5分ok 2.需要舍弃查询的相恋男女的直接边 3分ok 3.大坑 0000 与 -0000 使用int型无法区分男女的. 2分ok 想法:用string输入 看长度和第一位符…
1136 A Delayed Palindrome(20 分) 题意:给定字符串A,判断A是否是回文串.若不是,则将A反转得到B,A和B相加得C,若C是回文串,则A被称为a delayed palindrome:否则继续迭代. 分析:根据题意模拟. 1.C++写法. #include<cstdio> #include<cstring> #include<cstdlib> #include<string> #include<algorithm> #…