HDU 2614 Beat (DFS)
来源:互联网 发布:写安卓软件 编辑:程序博客网 时间:2024/06/05 07:25
题意: n*n的图,a[i][j]:表示做完i题目在做j题目需要耗费的时间,每次选择的题目耗费时间要不小于之前的,问最多能做几题
#include<iostream>#include<cstdlib>#include<cmath>#include<algorithm>#include<cstring>#include<cstdio>#include<queue>#include<set>#include<stack>#define cl(a,b) memset(a,b,sizeof(a));#define LL long long#define P pair<int,int>#define X first#define Y second#define out(x) cout<<x<<endl;using namespace std;const int maxn=20;const int inf=9999999;int a[maxn][maxn];int n;bool vis[maxn];int ans;void dfs(int row,int sum,int time){ ans=max(ans,sum); if(sum==n){ return; } for(int i=1;i<n;i++)if(!vis[i]){ if(a[row][i]>=time){ vis[i]=true; dfs(i,sum+1,a[row][i]); vis[i]=false; } }}int main(){ while(~scanf("%d",&n)){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ scanf("%d",&a[i][j]); } } cl(vis,false); ans=0; dfs(0,0,0); printf("%d\n",ans+1); } return 0;}
0 0
- HDU 2614 Beat (dfs)
- HDU 2614 Beat (DFS)
- 【DFS】 HDU 2614 Beat 水
- HDU 2614 Beat(dfs)
- HDU 2614 Beat (DFS)
- HDU 2614 Beat(DFS)
- HDU 2614 Beat(dfs)
- hdu 2614 Beat (dfs)
- hdu 2614 BEAT 回溯的dfs
- HDU 2614 Beat(dfs+回溯)
- hdu(2614) Beat
- hdu 2614 Beat
- HDU 2614 Beat
- hdu 2614 Beat
- HDU 2614 Beat
- hdu 2614 beat
- hdu 2614 Beat
- HDU 2614 Beat
- Swift和Objective-C混合编程——OC调用Swift
- Ubuntu 下的 SVN 工具
- 利用赛门铁克Symantec Endpoint Protection漏洞渗透企业网络
- CCS CMD文件
- HDU 5358 多校第6场 First One
- HDU 2614 Beat (DFS)
- URI, URL, URN
- yii2 多数据库操作
- bootstrap v3学习笔记之JavaScript插件
- "ALT+/" eclipse快捷键失效问题
- 实现IEnumerator 已支持foreach
- Android Studio实战技巧
- 37. Element appendChild() 方法
- android 5.0新特性学习总结之下拉刷新(一)