1 条题解

  • 0
    @ 2024-2-2 17:54:16

    难度不大,考虑用mapmap做。 直接给出AC Code

    #include <bits/stdc++.h>
    using namespace std;
    #define int long long
    const int N = 1e4 + 5;
    int n;
    map<string, string> m;
    string s, ans;
    signed main() {
        cin >> n;
        for (int i = 1; i <= n; i++) {
            string a, b;
            cin >> a >> b;
            m[a] = b;
        }
        cin >> s;
        s += '.';
        string t = "";
        for (char c : s) {
            if (c >= 'a' && c <= 'z')
                t += c;
            else {
                if (t != "") {
                    if (m.count(t))
                        ans += m[t];
                    else
                        ans += "UNK";
                    t = "";
                }
                ans += c;
            }
            // cout<<c<<" "<<ans<<" "<<t<<endl;
        }
        ans.pop_back();
        cout << ans << endl;
        return 0;
    }
    
    • 1

    信息

    ID
    9487
    时间
    1000ms
    内存
    512MiB
    难度
    2
    标签
    递交数
    1
    已通过
    1
    上传者