当前位置:网站首页>And an array merge rank by rank
And an array merge rank by rank
2022-08-08 05:46:00 【a little yu】
【Prisoning criminals】
Title description
There are two prisons in City S, which hold NN criminals, numbered 1-N1−N.The relationship between them is naturally very discordant.Many criminals even have long-standing grievances, and conflicts may break out at any time if objective conditions are met.We use "grievance value" (a positive integer value) to represent the degree of hatred between two criminals. The higher the hatred value, the more grievances between the two criminals.If two criminals with a grievance value of cc are held in the same prison, there will be friction between the two, resulting in a conflict event of influence cc.
At the end of each year, the police department will arrange a list of all conflict incidents in the prison in the current year in descending order of impact, and then report it to the mayor of City S, Z.The busy Mayor Z will only look at the impact of the first event on the list, and if the impact is bad, he will consider replacing the police chief.
After scrutinizing the conflicting relationships among the NN criminals, the police chief feels pressure.He plans to redistribute the criminals in the two prisons, in order to have less impact on the conflict, so as to keep his black gauze cap.Assuming that as long as there is hatred between two criminals in the same prison, then they will have friction at some time every year.
So, how should criminals be allocated to minimize the impact of the conflict that Mayor Z saw?What is this minimum value?
Input format
Separate two numbers on each line with a space.The first line consists of two positive integers N, MN, and M, which respectively represent the number of criminals and the number of pairs of criminals with hatred.The following MM lines each have three positive integers a_j,b_j,c_jaj,bj,cj, indicating that there is hatred between criminals a_jaj and b_jbj, and the resentment value is c_jcj.The data guarantees 1 A total of 11 lines, for the impact of the conflict that Mayor Z saw.Output Enter #1Copy Output #1Copy 【Explanation of input and output samples】The grievance value between criminals is shown in the left picture below, and the right picture shows the distribution method of criminals. The influence of conflict events seen by the mayor is 35123512 (by No. 22 and No. 33)No. criminals trigger).No other division method is better than this one. 【Data Range】 For 30\%30% of the data there is N\leq 15N≤15. For 70\%70% of the data there are N\leq 2000,M\leq 50000N≤2000,M≤50000. For 100\%100% of the data there are N\leq 20000,M\leq 100000N≤20000,M≤100000. 1. The enemy of the enemy is the friend 2. You don't need to merge by rank, you can pass the test yourself, it seems to improve the speed, when the amount of data is very large.Output format
0 if no conflict has occurred in the prison this year.Sample input and output
4 61 4 25342 3 35121 2 283511 3 66182 4 18053 4 12884
3512
Instructions/Tips

#include
边栏推荐
- 【图像处理】matlab基础图像处理 | 图像载入、图像添加噪声、图像滤波、图像卷积
- 14.Unity2D 横版 粒子系统特效 飙血粒子+高处落地粒子+对象池管理所有粒子
- Why do big Internet companies keep hiring while frantically laying off staff?
- Mail online cobalstrike fishing
- KDD'22 Recommendation System Papers (24 Research & 36 Application Papers)
- 【leetcode】剑指 Offer(专项突击版)汇总
- String title parsing
- 邮件钓鱼上线cobalstrike
- 让你的应用完美适配平板
- 【Redis】Redis学习——事务
猜你喜欢

Postman显示验证码图片(base64字符串)

Flutter 教程之高效且精美的滚动组件Slivers (教程含源码)

【leetcode】剑指 Offer(专项突击版)汇总

人体神经元细胞分布图片,神经元人体分布大图
![Talk about the principle and implementation of Redis distributed lock [Ant Financial Services Three Sides]](/img/ed/dbaeab544066b5dbf19e71bee0f8c9.png)
Talk about the principle and implementation of Redis distributed lock [Ant Financial Services Three Sides]

torch.gather() 用法解读

补坑 模拟散列表

Matlab simulation of photovoltaic mppt maximum power control based on disturbance observation method

121道分布式面试题和答案

【u-boot】u-boot的驱动模型分析
随机推荐
Week 8 Generative Adversarial Networks(生成对抗网络 GAN)
Several postman features worth collecting will help you do more with less!
28. Anomaly detection
gcc/g++ use
补坑 模拟散列表
TSF Microservice Governance Combat Series (2) - Service Routing
Query and track multiple express tracking numbers, and filter the tracking numbers shipped at a certain time
Promise的使用与async/await的使用
How to batch import files and rename them all to the same file name
Go-Excelize API源码阅读(十)—— SetActiveSheet(index int)
轮播文字! QPainter
【Win10】Several sleep problems and countermeasures
postman---postman parameterization
Synchronization and Asynchrony of Clocks
The CAP theorem instance analysis
Unity mouse cursor usage learning
让你的应用完美适配平板
Session 和 Cookie 使用
State Compression Review
Unity-CharacterController (Character Controller)