1 solutions

  • -3
    @ 2025-8-7 17:12:40

    自己写

    //@ma chen hao
    #include <bits/stdc++.h>
    #include <iostream>
    #include <vector>
    #include <stdio.h>
    #include <algorithm>
    using namespace std;
    int n;
    string s;
    map<string, string > m;
    
    int main() {
    	cin >> n;
    	while (n--) {
    		string a, b;
    		cin >> a >> b;
    		m[a] = b;
    	}
    	cin >> s;
    	s += '.';
    	int len = s.size();
    	string t = "";
    	string ans = "";
    
    	for (int i = 0; i < len; i++) {
    		if (s[i] >= 'a' && s[i] <= 'z')
    			t += s[i];
    		else {
    			if (t != "") {
    				if (m.count(t))
    					ans += m[t];
    				else
    					ans += "UNK";
    				t = "";
    			}
    			ans += s[i] ;
    		}
    	}
    
    	ans.pop_back();
    	cout << ans;
    }

    Information

    ID
    14733
    Time
    1000ms
    Memory
    512MiB
    Difficulty
    2
    Tags
    # Submissions
    56
    Accepted
    32
    Uploaded By