2 条题解
-
1魔阴身重度依赖 (lijunting) LV 7 @ 2024-11-24 16:35:03
#include<iostream> using namespace std; const int N = 20 + 10; const int INF = 0x3f3f3f; int ans,n; char a[N][N]; bool v[N]; void dfs(int step) { if(step == n + 1) { ans++; return; } for(int i = 1;i <= n;i++) { if(a[step][i] == '1' && !v[i]) { v[i] = 1; dfs(step + 1); v[i] = 0; } } } int main(){ cin >> n; for(int i = 1;i<=n;i++){ for(int j = 1;j<=n;j++){ cin >> a[i][j]; } } dfs(1); cout << ans; return 0; }
-
-12024-7-28 9:20:58@
#include<iostream> using namespace std; const int N = 20 +10; const int INF=0x3f3f3f; int ans,n; char a[N][N]; bool v[N]; void dfs(int step){ if(step == n + 1){ ans++; return; } for(int i = 1;i<=n;i++){ if(a[step][i] == '1' && !v[i]){ v[i] = 1; dfs(step+1); v[i] = 0; } } } int main(){ cin>>n; for(int i = 1;i<=n;i++){ for(int j = 1;j<=n;j++){ cin>>a[i][j]; } } dfs(1); cout<<ans; }
- 1
信息
- ID
- 3062
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 83
- 已通过
- 22
- 上传者