日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

1158 Telefraud Detection

發布時間:2024/1/18 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1158 Telefraud Detection 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。