
標程是用暴力列舉做的
#include <bits/stdc++.h>
using namespace std;
vector<string> a;
int n;
int b[10];
int ret;
void dfs(int i) {
if(i == a.size()) {
ret++;
} else {
for(int j = 0; j < a[i].size(); j++) {
if(b[a[i][j] - '0']) {
b[a[i][j] - '0'] = 0;
dfs(i + 1);
b[a[i][j] - '0'] = 1;
}
}
}
}
int main() {
cin >> n;
for(int i = 0; i < n; i++) {
string x; cin >> x;
a.push_back(x);
}
for(int i = 0; i < 10; i++) b[i] = 1;
ret = 0;
dfs(0);
cout << ret << endl;
return 0;
}
樓主愚笨,畫了半天草圖也不是很懂它的思路,或者說有別的思路歡迎指出
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/62979.html
標籤:基礎類
下一篇:到底哪里錯了,,抓狂,
