20pts
查看原帖
20pts
1419482
Backpack_dp楼主2025/6/16 22:14

map过不了怎么办

#include<bits/stdc++.h>
using namespace std;
map<string,string>m; 
char s[1145];
int main(){
	int q;
	cin>>q;
	while(q--){
		string a,b;
		cin>>a>>b;
		m[a]=b;
	}
	cin>>s;
	string t;
	int j=0;
	for(int i=0;i<strlen(s);i++){
		if(s[i]>='a'&&s[i]<='z'){
			t=t+s[i];
		}
		else{
			//cout<<t==""?"":(m[t]==""?"UNK":m[t]);t="";
			if(t=="")cout<<"";
			else{
				if(m[t]=="")cout<<"UNK";
				else cout<<m[t];
			}
			t="";	
			cout<<s[i];
		}
	}
	//cout<<(m[t]==""?"UNK":m[t]);
	if(m[t]=="")cout<<"UNK";
	else cout<<m[t];
	return 0;
}
2025/6/16 22:14
加载中...