DFS 专题 Beat
HINT 误导人,水题。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
# include <cstdio> # include <cstring> # define N 15 + 5 int n, ans; int f[N][N]; bool vis[N]; void dfs(int cur, int cnt, int t) { if (cnt > ans) ans = cnt; for (int i = 0; i < n; ++i) if (vis[i] == false && f[cur][i] >= t) { vis[i] = true; dfs(i, cnt+1, f[cur][i]); vis[i] = false; } } void init(void) { for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) scanf("%d", &f[i][j]); memset(vis, false, sizeof(vis)); } void solve(void) { ans = 1; vis[0] = true; dfs(0, 1, 0); printf("%d\n", ans); } int main() { while (~scanf("%d", &n)) { init(); solve(); } return 0; }
/**/