解法:
#include<iostream>
#include<vector>
using namespace std;
int arr[100][100];
int n;
int sta, des;
vector<int> path;
vector<vector<int>> res;
void dfs(vector<int> &a,int i) {
a[i] = 1;
path.push_back(i);
if (i == des) {
res.push_back(path);
return;
}
for (int j = 0; j < n; j++) {
if (arr[i][j]&&!a[j]) {
dfs(a,j);
path.pop_back();
a[j] = 0;
}
}
}
int main() {
cin >> n;
vector<int> vis(n, 0);
cin >> sta >> des;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
cin >> arr[i][j];
dfs(vis,sta);
for (int i = 0; i < res.size(); i++) {
for (int j = 0; j < res[i].size(); j++) {
cout << res[i][j];
}
cout << endl;
}
return 0;
}