CSES - Datatähti 2021 alku - Results
Submission details
Task:Sanalista
Sender:pyronk
Submission time:2020-09-30 21:40:21 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'bool even(std::__cxx11::string)':
input/code.cpp:9:25: error: 'count' is not a member of 'std'
         size_t n = std::count(str.begin(), str.end(), e);
                         ^~~~~
input/code.cpp:9:25: note: suggested alternative: 'cout'
         size_t n = std::count(str.begin(), str.end(), e);
                         ^~~~~
                         cout
input/code.cpp: In function 'int main()':
input/code.cpp:29:30: warning: converting to non-pointer type 'long int' from NULL [-Wconversion-null]
         (even(e) ? right++ : NULL);
                              ^~~~

Code

#include <iostream>
#include <vector>
#include <string>
using namespace std;
char alphabet[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
bool even(string str) {
    for (char e : alphabet) {
        size_t n = std::count(str.begin(), str.end(), e);
        if (n % 2 != 0) {
            return false;
        }
    }
    return true;
    
}

int main()
{
    vector<string> strings;
    string str;
    int amount;
    int right = 0;
    cin >> amount;
    for (int i = 0; i < amount; i++) {
        cin >> str; strings.push_back(str);
    }
    for (auto e : strings) {
        (even(e) ? right++ : NULL);
    }
    cout << right;
}