5 条题解

  • -4
    @ 2025-7-19 9:21:27

    #include<bits/stdc++.h> using namespace std;

    const int MAXN = 25; int n, ans; char arr[MAXN][MAXN]; bool v[MAXN];

    void dfs(int step) { if (step == n + 1) { ans++; return; } for (int i = 1; i <= n; i++) { if (arr[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 >> arr[i][j]; } }

    dfs(1);
    cout << ans << endl;
    return 0;
    

    }

    信息

    ID
    3062
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    递交数
    108
    已通过
    36
    上传者