当前位置:网站首页>Temporary cramming before DFS examination
Temporary cramming before DFS examination
2022-07-05 15:26:00 【Xuanhong Zhou】
subject
It is suggested to use for Cycle through , I don't want to write now
Code
/* Because you can think about two problems in the same subject at the same time , Suppose it's divided into left right Left and right brain So for n questions , Yes 2^n Maybe , Generally, you can run in one second 4 * 10 ^ 8 Time The maximum range of this question is 4* 2^20 =4*1048576 It can be searched directly Think of the search of this topic as the search of a binary tree The left subtree is the left brain , The right subtree is the right brain And then it's normal dfs dfs Medium x Is how many questions have been done ,y Is the total number of topics in the current subject , If x Than y big , That's a plan */
#include<iostream>
#include<algorithm>
using namespace std;
const int N=30;
int hh[N][5];
int s[5];
int ans=0;
int l=0,r=0;
int mini;
void dfs(int x,int y){
// Recursive export
//dfs Medium x Is how many questions have been done ,y Is the total number of topics in the current subject
// If x Than y big , That's a plan
// Now update the minimum , You should take the maximum time in your left and right brain , Then and current mini Take a small value
if(x>s[y]){
mini=min(max(l,r),mini);
return ;
}
l+=hh[x][y];
dfs(x+1,y);// These two lines will cause all to be placed on the left brain
l-=hh[x][y];// Then go back
r+=hh[x][y];// Put it on the right brain
dfs(x+1,y);
r-=hh[x][y];
}
int main(){
cin>>s[1]>>s[2]>>s[3]>>s[4];
for(int i=1;i<=4;i++){
mini=19260816;
l=r=0;
for(int j=1;j<=s[i];j++)
cin>>hh[j][i];
dfs(1,i);
ans+=mini;
}
cout<<ans;
return 0;
}
边栏推荐
- Install PHP extension spoole
- go学习 ------jwt的相关知识
- MySQL 巨坑:update 更新慎用影响行数做判断!!!
- How can the boss choose programmers to help me with development?
- Machine learning notes - gray wolf optimization
- I collect multiple Oracle tables at the same time. After collecting for a while, I will report that Oracle's OGA memory is exceeded. Have you encountered it?
- 你童年的快乐,都是被它承包了
- Common MySQL interview questions
- How can I quickly check whether there is an error after FreeSurfer runs Recon all—— Core command tail redirection
- Huawei Hubble incarnation hard technology IPO harvester
猜你喜欢
How to paste the contents copied by the computer into mobaxterm? How to copy and paste
Nine hours, nine people, nine doors problem solving Report
MySQL之CRUD
Bugku's eyes are not real
Ecotone technology has passed ISO27001 and iso21434 safety management system certification
P1451 calculate the number of cells / 1329: [example 8.2] cells
Huiyuan, 30, is going to have a new owner
Common redis data types and application scenarios
Stop B makes short videos, learns Tiktok to die, learns YouTube to live?
Bugku easy_ nbt
随机推荐
Redis' transaction mechanism
Machine learning notes - gray wolf optimization
I spring web upload
超越PaLM!北大硕士提出DiVeRSe,全面刷新NLP推理排行榜
机器学习笔记 - 灰狼优化
GPS original coordinates to Baidu map coordinates (pure C code)
Reproduce ThinkPHP 2 X Arbitrary Code Execution Vulnerability
PHP high concurrency and large traffic solution (PHP interview theory question)
Creation and use of thymeleaf template
ionic cordova项目修改插件
Where is the operation of convertible bond renewal? Is it safer and more reliable to open an account
Misc Basic test method and knowledge points of CTF
Ctfshow web entry command execution
Bugku easy_ nbt
Optional parameters in the for loop
queryRunner. Query method
sql server char nchar varchar和nvarchar的区别
Garbage collection mechanism of PHP (theoretical questions of PHP interview)
Bugku cyberpunk
Summary of the third class