每次re的点都不一样,这是为什么?求大佬解答
  • 板块P2814 家谱
  • 楼主wowozai
  • 当前回复3
  • 已保存回复3
  • 发布时间2021/3/21 12:16
  • 上次更新2023/11/5 01:47:49
查看原帖
每次re的点都不一样,这是为什么?求大佬解答
355996
wowozai楼主2021/3/21 12:16
#include <iostream>
#include <map>
#include <string>
using namespace std;
map<string,string> m;
string s1,s2;
string fd(string s){
	if(s!=m[s]){
		m[s]=fd(m[s]);
	}
	return m[s];
}
int main(){
	char c,now;
	cin >> c;
	while(c!='$'){
		if(c=='#'){
			cin >> s1;
			if(m[s1]==""){
				m[s1]=s1;
			}
			cin >> now;
			while(now=='+'){
				cin >> s2;
				m[s2]=s1;
				cin >> now;
			}
			c=now;
		}else if(c=='?'){
			cin >> s1;
			cout << s1 << " " << fd(s1) << endl;
			cin >> c;
		}
	}
	return 0;
} 
2021/3/21 12:16
加载中...