干自闭

关注

501B - Misha and Changing Handles

干自闭

关注

阅读 71

2022-03-13

只能说这题体现了map的能力很强大

#include<bits/stdc++.h>

using namespace std;

const int N = 1010;

int main(){
    map<string,string> m;
	int n;
	cin>>n;
	string a,b;
	while(n--){
		cin>>a>>b;
		if(m.count(a)==0){
			m[a] = a;
		}
		m[b] = m[a];
		m.erase(a);	
	}
	cout<<m.size()<<endl;
	for(auto it=m.begin();it!=m.end();it++){
		cout<<it->second<<" "<<it->first<<endl;
	} 
  
}

相关推荐

非宁静不致远

Codeforces Round #285 (Div. 2) B. Misha and Changing Handles map 映射

非宁静不致远 55 0 0

有点d伤

【CodeForces - 501C】Misha and Forest (思维构造,树,数学异或)

有点d伤 34 0 0

一葉_code

Misha and Permutations Summation

一葉_code 97 0 0

迎月兮

Android Brightness Changing

迎月兮 139 0 0

你带来了我的快乐

hObject==handles.pushbutton1;sprintf('handles.pushbutton1 is %d',handles.pushbutton1)

你带来了我的快乐 14 0 0

yundejia

chmod: changing permissions of ‘xxx‘: Operation not permitted

yundejia 61 0 0

左手梦圆

java mail 501 5.1.7

左手梦圆 42 0 0

耳一文

已解决No handles with labels found to put in legend

耳一文 37 0 0

进击的包籽

MATLABGUI中的handles 数据传递

进击的包籽 65 0 0

zibianqu

Codeforces Round #285 (Div. 2) C. Misha and Forest

zibianqu 96 0 0

精彩评论(0)

0 0 举报