CSES - Datatähti 2016 alku - Results
Submission details
Task:Osajono
Sender:felixbade
Submission time:2015-10-11 23:05:54 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:14:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.length(); i++) {
                       ^
input/code.cpp:21:17: error: cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'
         cout << x << endl;
                 ^
In file included from /usr/include/c++/4.9/iostream:39:0,
                 from input/code.cpp:2:
/usr/include/c++/4.9/ostream:602:5: note: initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = std::pair<const char, int>]'
     operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
     ^

Code

# include <cstdlib>
# include <iostream>
# include <iomanip>
#include <map>

using namespace std;


int main()
{
    string s;
    cin >> s;
    map<char,int> st;
    for (int i = 0; i < s.length(); i++) {
        if (!st.count(s[i])) {
            st[s[i]] = 0;
        }
        st[s[i]]++;
    }
    for (auto x : st) {
        cout << x << endl;
    }
}