40pts球条
查看原帖
40pts球条
1353691
lee_0730楼主2024/9/28 15:10

rt,这是代码

#include<bits/stdc++.h>
using namespace std;
string nu;
int k;
map<char,vector<char>>op;
map<string,int>num;
int dfs(string s){
	num[s]++;
	if(num[s]!=1){
		return 0;
	}
	int i=0;
	for(auto ch:s){
		if(!op[ch].empty()){
			for(auto opr:op[ch]){
				string s1=s;
				s1[i]=opr;
				dfs(s1);
			}
		}
		i++;
	}
	return 0;
}
int main(){
	cin>>nu>>k;
	char o,n;
	while(k--){
		cin>>o>>n;
		op[o].push_back(n);
	}
	dfs(nu);
	cout<<num.size();
	return 0;
}

开了O2: 1MLE 2TLE

没开O2: 3TLE

2024/9/28 15:10
加载中...