Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
121529 梁乃元 人际关系 C++ 运行超时 70 2006 MS 252 KB 615 2024-01-21 22:06:59

Tests(7/10):


# include <bits/stdc++.h> using namespace std ; bool flg [105] [105] ; bool vst [105] ; int mn = 114514 , n , a , b ; void dfs ( int x , int cnt ) { if ( x == b ) { mn = min ( mn , cnt - 1 ) ; return ; } for ( int i = 1 ; i <= n ; i ++ ) { if ( ! vst [i] and flg [x] [i] ) { vst [i] = true ; dfs ( i , cnt + 1 ) ; vst [i] = false ; } } } int main ( ) { cin >> n >> a >> b ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { cin >> flg [i] [j] ; } } vst [a] = true ; dfs ( a , 0 ) ; cout << mn << endl ; return 0 ; }


测评信息: