Telefraud(电信诈骗) remains a common and persistent problem in our society. In some cases, unsuspecting victims lose their entire life savings. To stop this crime, you are supposed to write a program to detect those suspects from a huge amount of phone call records.

A person must be detected as a suspect if he/she makes more than K short phone calls to different people everyday, but no more than 20% of these people would call back. And more, if two suspects are calling each other, we say they might belong to the same gang. A makes a short phone call to B means that the total duration of the calls from A to B is no more than 5 minutes.

Input Specification:

Each input file contains one test case. For each case, the first line gives 3 positive integers K (≤500, the threshold(阈值) of the amount of short phone calls), N (≤103, the number of different phone numbers), and M (≤105, the number of phone call records). Then M lines of one day's records are given, each in the format:

caller receiver duration

where caller and receiver are numbered from 1 to N, and duration is no more than 1440 minutes in a day.

Output Specification:

Print in each line all the detected suspects in a gang, in ascending order of their numbers. The gangs are printed in ascending order of their first members. The numbers in a line must be separated by exactly 1 space, and there must be no extra space at the beginning or the end of the line.

If no one is detected, output None instead.

Sample Input 1:

5 15 31
1 4 2
1 5 2
1 5 4
1 7 5
1 8 3
1 9 1
1 6 5
1 15 2
1 15 5
3 2 2
3 5 15
3 13 1
3 12 1
3 14 1
3 10 2
3 11 5
5 2 1
5 3 10
5 1 1
5 7 2
5 6 1
5 13 4
5 15 1
11 10 5
12 14 1
6 1 1
6 9 2
6 10 5
6 11 2
6 12 1
6 13 1

Sample Output 1:

3 5
6

Note: In sample 1, although 1 had 9 records, but there were 7 distinct receivers, among which 5 and 15 both had conversations lasted more than 5 minutes in total. Hence 1 had made 5 short phone calls and didn't exceed the threshold 5, and therefore is not a suspect.

Sample Input 2:

5 7 8
1 2 1
1 3 1
1 4 1
1 5 1
1 6 1
1 7 1
2 1 1
3 1 1

Sample Output 2:

None

(1)输入时,记录每对打电话和接电话人的通话时长;

(2)二重循环遍历所有两人组合,如果两人之间的通话时间总和不超过5分钟,记为有效通话,同时如果反过来,这组接电话的人有回电话,即时间大于零,就记这组打电话的人被回了一次电话。

(3)从1到N遍历编号,如果有效通话次数大于k并且被回电话的次数不超过20%,则把这个人列为嫌疑人。

(4)嫌疑人个数为0则直接输出none

(5)并查集分帮派,二重循环遍历所有嫌疑人的两人组合,如果两个人互相打过电话,则merge。

(6)遍历所有嫌疑人,以嫌疑人并查集中的父节点作为下标,建立帮派结构体,记录每个帮派中嫌疑人的数量和编号。

(7)对每个帮派中的所有嫌疑人进行升序排序

(8)对帮派进行排序

(9)输出

1158 Telefraud Detection相关推荐

  1. PAT(甲级)2019年春季考试 7-3 Telefraud Detection

    1. 这题复杂在诈骗检测算法的理解 怎样的一个人会被判定成嫌疑犯呢? 他打出给别人的累计通话时长的不同的人数大于K 注意:不同和累计 怎样的两个人会被判定成同伙呢? 相互之间有通话记录 2. 同伙的合 ...

  2. 2020年9月PAT甲级满分必备刷题技巧

    2020年7月的考试结束了,除了本次的考题更新,短期内不会更新. [7月题目的特点:首次线上考试,没出链表.树相关的模板题,第2到4题背景新颖,大大降低了抄袭历年代码的可能性,可以看作是线上考试的新趋 ...

  3. 力扣PTA~每天至少三题

    文章目录 算法 双指针 平方数之和 167.两数之和-输入有序数组 Reverse Vowels of a string 二分法 153. Find Minimum in Rotated Sorted ...

  4. 阿里云资深技术专家易立:我对云原生软件架构的观察与思考

    来源 | 阿里巴巴中间件 作者 | 易立,阿里云资深技术专家,容器技术负责人 头图 | CSDN付费下载于视觉中国 前言 云原生计算包含三个维度的内容,云原生基础设施,软件架构和交付与运维体系,本文将 ...

  5. PAT(甲级)2019春季考试(Python实现)

    7-1 Sexy Primes 7-1 Sexy Primes 分数 20 作者 陈越 单位 浙江大学Sexy primes are pairs of primes of the form (p, p ...

  6. 李宏毅(2020)作业10:异常检测(Anomaly Detection)

    文章目录 数据集 目标 数据 作业 KNN PCA Autoencoder 评估 数据集 数据集下载test 数据集下载train 目标 Semi-supervised anomaly detecti ...

  7. Single Shot Multibox Detection (SSD)实战(下)

    Single Shot Multibox Detection (SSD)实战(下) Training 将逐步解释如何训练SSD模型进行目标检测. 2.1. Data Reading and Initi ...

  8. Single Shot Multibox Detection (SSD)实战(上)

    Single Shot Multibox Detection (SSD)实战(上) 介绍了边界框.锚框.多尺度对象检测和数据集.现在,我们将利用这些背景知识构建一个目标检测模型:单次多盒检测(SSD) ...

  9. 目标检测数据集The Object Detection Dataset

    目标检测数据集The Object Detection Dataset 在目标检测领域,没有像MNIST或Fashion MNIST这样的小数据集.为了快速测试模型,我们将组装一个小数据集.首先,我们 ...

最新文章

  1. 因并发而生,因云计算而热
  2. tomcat的部署及session绑定反代
  3. 同步阻塞处理的几种方法
  4. python functools import wraps_python装饰器中functools.wraps的作用详解
  5. 2017第八届蓝桥杯C/C++ B组省赛 —— 第一题:购物单
  6. react打包后图片丢失_React中型项目的优化实践
  7. 计算机是如何诞生的?
  8. 多态和类属性、类方法
  9. 使用LINQ计算基本统计
  10. ios pan手势滑动消失动画_iOS仿抖音—评论视图滑动消失
  11. 注册cn域名应该注意些什么
  12. HDU 1358 Period【KMP】
  13. 2017招商银行笔试01
  14. 软件混沌工程原则以及应用介绍(PRINCIPLES OF CHAOS ENGINEERING)
  15. java实现一元线性回归算法
  16. MySQL6天笔记——day01
  17. php获取本机IP地址
  18. 只需一个DOM,纯CSS实现线性跑马灯特效
  19. 中国矿业大学计算机保研去向,中国矿业大学2020届保研率19%,保研本校242人
  20. 计算机信息加工是指什么作用,什么是信息加工信息加工的方式

热门文章

  1. caffe2 windows安装
  2. 把IE浏览器的背景改成保护视力的颜色
  3. h5登录闪退_传奇登录器突然间闪退
  4. 商业合伙人和技术合伙人之间的矛盾与解决-评估商业合伙人和技术合伙人的能力和价值
  5. python基础学习DAY4——转自金角大王
  6. redis使用本地磁盘做pvc
  7. 【多元统计分析】04.多元正态分布的参数估计
  8. 算法题:解密(楚楚街2016招聘笔试)
  9. Hex字符串转byte数组 汉字转byte数组
  10. Java路径问题的汇总(绝对路径、相对路径、yml、Java程序)