Skip to content
On this page

d57_q0_histogram.cpp

cpp
#include <iostream>
#include <map>
#include <string>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int N;
    std::cin >> N;
    std::map<std::string, int> hist;

    for (int i = 0; i < N; i++) {
        std::string key;
        std::cin >> key;

        hist[key]++;
    }

    for (const auto& [key, value] : hist) {
        if (value <= 1) continue;

        std::cout << key << " " << value << "\n";
    }
}

See on GitHub

Last Updated: 15/1/2567 13:25:21 (UTC+7)

Released under the MIT License