当前位置:网站首页>The real topic of the 11th provincial competition of Bluebridge cup 2020 - crop hybridization
The real topic of the 11th provincial competition of Bluebridge cup 2020 - crop hybridization
2022-07-01 01:00:00 【paidx0】
Title Description
Crop hybridization is an important step in crop cultivation . It is known that there is N Grow crops ( Number 1 to N), The first i The time from sowing to maturity of a crop is Ti. Crops can be crossed in pairs , The hybridization time is the longer of the two .
Such as crops A The planting time is 5 God , crop B The planting time is 7 God , be AB The time taken for hybridization is 7 God . Crop hybridization produces fixed crops , New crops still belong to N One of the crops .
At the beginning , Have one of them M The seeds of a crop ( The number is unlimited , It can support multiple hybridization ). Multiple hybridization processes can be carried out at the same time .
Ask for a given target seed , At least how many days will it take to get .
If it exists 4 Grow crops ABCD, The respective maturity time is 5 God 、7 God 、3 God 、8 God . Initial possession AB The seeds of two crops , Target seed is D, The known hybridization situation is A×B→C,A×C→D.
The shortest hybridization process is :
The first 1 To the first day 7 God ( crop B Time for ),A×B→C.
The first 8 To the first day 12 God ( crop A Time for ),A×C→D. cost 12 Days get crops D Seeds .
Input
Input the 1 Line inclusion 4 It's an integer N,M,K,T,N Indicates the total number of crop species ( Number 1 to N),M Indicates the number of crop seed types initially owned ,K Indicates the number of hybridization schemes ,T Indicates the number of the target seed . The first 2 Line inclusion N It's an integer , Among them the first i An integer represents the th i The planting time of crops Ti(1≤Ti≤100). The first 3 Line inclusion M It's an integer , Each represents the seed type already owned Kj(1≤Kj≤M),Kj Two are different . The first 4 to K+3 That's ok , Each row contains 3 It's an integer A,B,C, It means the first one A Category crops and category B The third kind of crops can be obtained by hybridization C The seeds of such crops .
Output
Output an integer , Indicates the shortest hybridization time to obtain the target seed .
The sample input
6 2 4 6
5 3 4 6 4 9
1 2
1 2 3
1 3 4
2 3 5
4 5 6
Sample output
16
use python The timeout is a bit serious , But keep a record , Record an idea
import math
N, M, K, T = map(int, input().split())
times = list(map(int, input().split())) # Crop ripening time
have = list(map(int, input().split())) # Crops already obtained
ways = [] # Hybrid program
for i in range(K):
ways.append(list(map(int, input().split())))
def dfs(T):
# exit
if T in have:
return 0
# Target seeds
time = math.inf
for i in ways:
if i[2] == T:
tmp = max(times[i[0]-1], times[i[1]-1])
min_t = max(dfs(i[0]), dfs(i[1])) + tmp
time = min_t
return time
print(dfs(T))
边栏推荐
- C # generates PPK files in putty format (supports passphrase)
- IBL预计算的疑问终于解开了
- 2022就要过去一半了,挣钱好难
- [original] PLSQL index sorting optimization
- P4 learning - p4runtime
- Search rotation sort array
- CentOS installation starts redis
- 写给 5000 粉丝的一封信!
- CTF tool (1) -- archpr -- including installation / use process
- Set different background colors for the border and text of the button
猜你喜欢

Vulnerability discovery - App application vulnerability probe type utilization and repair

Oracle-数据完整性

2022-2028 global retro glass industry research and trend analysis report

写给 5000 粉丝的一封信!

Line number of Jenkins pipeline script execution exception

Two-stage RO: part 1

Get to know the drawing component of flutter - custompaint

CTF tool (1) -- archpr -- including installation / use process

Chapter 53 overall understanding of procedures from the perspective of business logic implementation

Implementation of OSD on Hisilicon platform (1)
随机推荐
A single element in an ordered array
Cloud security daily 220630: the IBM data protection platform has found an arbitrary code execution vulnerability, which needs to be upgraded as soon as possible
2022 is half way through. It's hard to make money
2022-2028 global rotary transmission system industry research and trend analysis report
C WinForm program interface optimization example
【原创】 PLSQL 索引排序优化
2022-2028 global public address fire alarm system industry research and trend analysis report
剑指 Offer 19. 正则表达式匹配
Examples of topological sequences
Redis - understand the master-slave replication mechanism
20220215 misc buctf easycap Wireshark tracks TCP flow hidden key (use of WinHex tool)
[DaVinci developer topic] -37- detail IRV: introduction to inter runnable variable + configuration
Error 2059 when Navicat connects to MySQL
Multi graph explanation of resource preemption in yarn capacity scheduling
ArrayList分析1-循环、扩容、版本
[untitled]
2022-2028 global weight loss ginger tea industry research and trend analysis report
The programmer's girlfriend gave me a fatigue driving test
Two-stage RO: part 1
20220216 misc buuctf backdoor killing (d shield scanning) - clues in the packet (Base64 to image)