当前位置:网站首页>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))
边栏推荐
- Two-stage RO: part 1
- Sword finger offer 18 Delete the node of the linked list
- 20220216 misc buuctf backdoor killing (d shield scanning) - clues in the packet (Base64 to image)
- 2022-2028 global plant peptone industry research and trend analysis report
- P4 learning - Basic tunneling
- 2022-2028 global mobile scanning radiology room industry survey and trend analysis report
- Solving the weird problem that the query conditions affect the value of query fields in MySQL query
- 什么是产品思维
- Ranger plug-in development (Part 2)
- Rhai - rust's embedded scripting engine
猜你喜欢
优质的水泵 SolidWorks模型素材推荐,不容错过
Mindjet mindmanager2022 mind map decompression installer tutorial
20220215 CTF misc buuctf the world in the mirror the use of stegsolve tool data extract
Wechat official account development (1) introduction to wechat official account
Basic knowledge of Embedded Network - introduction of mqtt
Ranger plug-in development (Part 2)
C language file operation for conquering C language
High quality pump SolidWorks model material recommended, not to be missed
2022-2028 global public address fire alarm system industry research and trend analysis report
2022-2028 global carbon fiber room scraper system industry research and trend analysis report
随机推荐
1009 product of polynomials (25 points) [PTA class A]
A single element in an ordered array
Get screen height
2022-2028 global rotary transmission system industry research and trend analysis report
Introduction to ES6 promise, new features of ES7 and es8 async and await
[DaVinci developer topic] -37- detail IRV: introduction to inter runnable variable + configuration
Pytorch auto derivation
剑指 Offer 18. 删除链表的节点
Authentication principle of Ranger plug-in
Redis - how to understand publishing and subscribing
2022-2028 global mobile scanning radiology room industry survey and trend analysis report
优质的水泵 SolidWorks模型素材推荐,不容错过
Confirm() method of window
双链表:初始化 插入 删除 遍历
对libco的一点看法
Problem solving: how to manage thread_local pointer variables
2022-2028 global weight loss ginger tea industry research and trend analysis report
Error msb8031: building an MFC project for a non Unicode character set is deprecated
Oracle data integrity
【日常记录】——对BigDecimal除法运算时遇到的Bug