WA+AC+AC+WA+MLE
查看原帖
WA+AC+AC+WA+MLE
729386
_Fancy_楼主2022/8/1 13:10
#include <bits/stdc++.h>
using namespace std;
string n;
map<string, int> op;
int a, ans;
vector<int> ho[10];
void dfs(string h, int dep){
	if(dep == n.size()){
		if(!op[h] != 0){
			ans++;
			op[h]++;
		}
		return;
	}
	if(dep > n.size()){
		return;
	}
	dfs(h, dep + 1);
	for(int i = 0;i < ho[h[dep] - '0'].size();i++){
		h[dep] = ho[h[dep] - '0'][i] + '0';
		dfs(h, dep + 1);
	}
}
int main() {
    cin >> n >> a;
    for(int i = 0;i < a;i++){
    	int k, l;
    	cin >> k >> l;
    	ho[k].push_back(l);
	}
	dfs(n, 0);
	cout << ans;
    return 0;
}
2022/8/1 13:10
加载中...