【DFS】 HDU 2614 Beat 水
来源:互联网 发布:手机淘宝6.10.10版本 编辑:程序博客网 时间:2024/05/29 17:48
开始必须写第0 道, Tij 表示上一道写 i 题 再写 j 题的花费
要求 cost j >= cost i
#include <cstdio>#include <cstring>#include <cstdlib>#include <string>#include <iostream>#include <algorithm>#include <sstream>#include <cmath>using namespace std;#include <queue>#include <stack>#include <vector>#include <deque>#define cler(arr, val) memset(arr, val, sizeof(arr))#define FOR(i,a,b) for(int i=a;i<=b;i++)#define IN freopen ("in.txt" , "r" , stdin);#define OUT freopen ("out.txt" , "w" , stdout);typedef long long LL;const int MAXN = 1010;const int MAXM = 6000010;const int INF = 0x3f3f3f3f;const int mod = 1000003;const double eps= 1e-8;#define lson l,m, rt<<1#define rson m+1,r,rt<<1|1int n,ans;int mp[16][16];bool vis[144];int dfs(int x,int m,int deep){ ans=max(deep,ans); for(int i=0;i<n;i++) { if(vis[i]) continue; if(mp[x][i]<m) continue; vis[i]=true; dfs(i,mp[x][i],deep+1); vis[i]=false; }}int main(){#ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout);#endif while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++) for(int j=0;j<n;j++) scanf("%d",&mp[i][j]); cler(vis,0); ans=0; vis[0]=true; dfs(0,0,0); cout<<ans+1<<endl; } return 0;}
0 0
- 【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 回溯的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
- 前端实用的东西--持续更新
- HBase二级索引与Join
- useful resources raspberry pi
- 数据结构与算法
- eclipse debug调试快捷键
- 【DFS】 HDU 2614 Beat 水
- iOS 使用FMDB进行数据库操作
- View Frustum Culling
- 【例 2.14】
- 第9周项目——星图补录 (f)
- 历史上最伟大的12位程序员
- 第九周项目1-利用循环求和(for语句)
- 大图片根据分辨率自适应宽度
- Java GC 算法总结