7-3 Telefraud Detection (25 分| 并查集| 查找合并,附详细注释,逻辑分析)

写在前面
  • 思路分析
    • 先得到suspects的值,将每个人与他人的电话总时间小于等于5的都存储下来,在去找人数小于等于k的,并且回拨人数不超过他拨出去的20%
    • 并查集将suspects进行分类
  • 问题点
    • 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.
      • 总时长
  • 知识半盲点,学习ing
测试用例
  • input:
    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
    output:
    3 5
    6
    
    input:
    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
    output:
    None
    
ac代码
  • 学习代码
    #include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
    int e[1005][1005], k, n, m, father[1005];
    const int inf = 0x7fffffff;
    int findfather(int x){
    	int a = x;
    	while(x != father[x])
    		x = father[x];
    	while(a != x){
    		int z = father[a];
    		father[a] = x;
    		a = z;
    	}
    	return x;
    }
    void Union(int a, int b){
    	int faa = findfather(a), fab = findfather(b);
    	if(faa != fab){
    	  father[fab] = min(faa, fab);
    	  father[faa] = min(faa, fab);
    	}
    }
    int main(){
    	scanf("%d %d %d", &k, &n, &m);
    	vector<int>num[n + 1], suspect;
    	fill(e[0], e[0] + 1005 * 1005, inf);
    	for(int i = 0; i < m; ++ i){
    		int a, b, temp;
    		scanf("%d %d %d", &a, &b, &temp);
    		if(e[a][b] == inf)
    			e[a][b] = 0;
    		e[a][b] += temp;
    	}
    	for(int i = 1; i <= n; ++ i)
    		for(int j = 1; j <= n; ++ j)
    			if(e[i][j] <= 5)
    				num[i].push_back(j); 
    	for(int i = 1; i <= n; ++ i){
    		int len = num[i].size(), cnt = 0;
    		if(len <= k)
    			continue;
    		for(int j = 0; j < num[i].size(); ++ j)
    			if(e[num[i][j]][i] < inf)
    				++ cnt;
    		if(cnt <= (int) (0.2 * len))
    			suspect.push_back(i);
    	}
    	if(suspect.size() == 0)
    		printf("None\n");
    	else{
    		for(int i = 1; i <= n; ++ i)
    			father[i] = i;
    		for(int i = 0; i < suspect.size(); ++ i)
    			for(int j = i + 1; j < suspect.size(); ++ j)
    				if(e[suspect[i]][suspect[j]] < inf && e[suspect[j]][suspect[i]] < inf)
    					Union(suspect[i], suspect[j]);
    		vector<int>ans[n + 1];
    		for(int i = 0; i < suspect.size(); ++ i)
    			ans[findfather(suspect[i])].push_back(suspect[i]);
    		for(int i = 1; i <= n; ++ i){
    			if(ans[i].size() != 0){
    				sort(ans[i].begin(), ans[i].end());
    				for(int j = 0; j < ans[i].size(); ++ j){
    					if(j != 0)
    						printf(" ");
    					printf("%d",ans[i][j]);
    				}
    				printf("\n");
    			}
    		}
    	}
    }
    
"traffic-light-detection-using-yolov3" 是一种使用 YOLOv3 模型来进行交通信号灯检测的方法。 YOLOv3 是一种基于深度学习的物体检测模型,它能够实时地对图像中的物体进行快速准确的检测。通过训练 YOLOv3 模型,并使用大量的交通信号灯图像数据集进行训练,我们就可以实现交通信号灯的自动检测了。 在交通信号灯检测过程中,首先需要收集大量的交通信号灯图像数据,并进行标注。标注的过程包括对图像中的交通信号灯位置进行标记,这样模型才能学习到交通信号灯的特征。然后,使用标注的数据集来训练 YOLOv3 模型,使其能够准确地检测到交通信号灯。 训练完成后,我们可以通过将交通信号灯图像输入到训练好的 YOLOv3 模型中,模型将会返回图像中所有检测到的交通信号灯位置和类别信息。这样,我们就可以实时地通过摄像头捕获的图像来进行交通信号灯检测了。 使用 YOLOv3 进行交通信号灯检测相比其他方法具有以下优势: 1. 实时性:YOLOv3 模型具有较高的检测速度,能够实现实时的交通信号灯检测。 2. 准确性:经过大量的训练,YOLOv3 模型能够准确地检测交通信号灯,减少了误检和漏检的情况。 3. 灵活性:YOLOv3 模型可以适应不同的交通信号灯形状和颜色,能够应对各种道路场景。 总结而言,"traffic-light-detection-using-yolov3" 是一种使用 YOLOv3 模型来进行交通信号灯检测的方法,它能够实现实时准确的交通信号灯检测,并具有较高的灵活性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xsimah

创作不易,感谢客官的打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值