当前位置:网站首页>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))
边栏推荐
- 20220215 misc buctf easycap Wireshark tracks TCP flow hidden key (use of WinHex tool)
- 剑指 Offer 19. 正则表达式匹配
- C#生成putty格式的ppk文件(支持passphrase)
- Introduction to ES6 promise, new features of ES7 and es8 async and await
- 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
- Deployment of mini version message queue based on redis6.0
- Set different background colors for the border and text of the button
- 给按钮的边框和文字设置不同的背景色
- File reading and writing for rust file system processing - rust Practice Guide
- IBL预计算的疑问终于解开了
猜你喜欢

Wechat official account development (1) introduction to wechat official account

Sword finger offer 18 Delete the node of the linked list

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

left join左连接匹配数据为NULL时显示指定值

Line number of Jenkins pipeline script execution exception

2022-2028 global electric yacht industry research and trend analysis report

2022-2028 global ethylene oxide scrubber industry research and trend analysis report

2022-2028 global herbal diet tea industry research and trend analysis report

2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report

SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding
随机推荐
Luogu p1144 shortest circuit count
Teach you how to use Hal library to get started -- become a lighting master
leetcode 474. Ones and zeroes (medium)
Get to know the drawing component of flutter - custompaint
The question of IBL precomputation is finally solved
P4 learning - p4runtime
Cmu15445 (fall 2019) project 1 - buffer pool details
What is product thinking
Basic data structure of redis
The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
Two-stage RO: part 1
解决 error MSB8031: Building an MFC project for a non-Unicode character set is deprecated.
Sword finger offer 18 Delete the node of the linked list
Bugku CTF daily one question dark cloud invitation code
ArrayList analysis 1-cycle, capacity expansion, version
Oracle data integrity
双链表:初始化 插入 删除 遍历
Redis - cache penetration, cache breakdown, cache avalanche
$watch will not trigger data change - $watch not firing on data change
魔王冷饭||#101 魔王解惑数量多与质量;员工管理;高考志愿填报;游戏架构设计