1 条题解

  • 1
    @ 2026-8-29 17:06:33
    #include <map>
    #include <string>
    using namespace std;
    
    char toDigit(char c) {
        if (c >= '0' && c <= '9') return c;
        if (c >= 'a' && c <= 'z') c -= 32;
        if (c <= 'C') return '2';
        if (c <= 'F') return '3';
        if (c <= 'I') return '4';
        if (c <= 'L') return '5';
        if (c <= 'O') return '6';
        if (c <= 'S') return '7';
        if (c <= 'V') return '8';
        return '9';
    }
    
    int main() {
        int n;
        cin >> n;
        map<string, int> cnt;
        for (int i = 0; i < n; i++) {
            string s;
            cin >> s;
            string num = "";
            for (char c : s) {
                if (c == '-') continue;
                num += toDigit(c);
            }
            string stdFmt = num.substr(0, 3) + "-" + num.substr(3, 4);
            cnt[stdFmt]++;
        }
        bool hasDup = false;
        for (auto& p : cnt) {
            if (p.second > 1) {
                cout << p.first << " " << p.second << endl;
                hasDup = true;
            }
        }
        if (!hasDup) {
            cout << "No duplicates." << endl;
        }
        return 0;
    }
    
    
    
    • 1

    信息

    ID
    1083
    时间
    2000ms
    内存
    64MiB
    难度
    10
    标签
    递交数
    3
    已通过
    1
    上传者