Task: | Sanalista |
Sender: | Lentsu |
Submission time: | 2020-10-05 19:43:30 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.01 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.01 s | details |
Code
#include <iostream>#include <map>int main() {int number_of_words;std::cin >> number_of_words;int sum_of_even_words = 0;std::string word;std::map<char, int> ocs;bool b;for(int i = 0; i != number_of_words; ++i){//get word from input streamstd::cin >> word;//set validity-boolean to trueb = true;//A word with even number of specific characters can't have an odd lengthfor(std::string::const_iterator it = word.begin(); it != word.end(); ++it)if(ocs.find(*it) == ocs.end())//add character occurence to mapocs.insert(std::make_pair(*it, 1));else//increment occurences++ocs[*it];for(std::map<char, int>::const_iterator it = ocs.begin(); it != ocs.end(); ++it)if(it->second % 2 != 0)//if an odd number of occurences, set validity to falseb = false;if(b)++sum_of_even_words;//clear the character occurence mapocs.clear();}std::cout << sum_of_even_words << std::endl;return 0;}
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1000 korvata sopimusaika nuhatartunta korttiautomaatti ... |
correct output |
---|
15 |
user output |
---|
15 |
Test 2
Verdict: ACCEPTED
input |
---|
1000 pub hansikaslokero erikoisvalmisteinen unijukka ... |
correct output |
---|
42 |
user output |
---|
42 |
Test 3
Verdict: ACCEPTED
input |
---|
1000 haapalastu toipumisaika mustalaiskieli taidelainaamo ... |
correct output |
---|
70 |
user output |
---|
70 |