| Task: | Sanalista |
| Sender: | Lentsu |
| Submission time: | 2020-10-05 19:23:03 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.01 s | details |
| #2 | WRONG ANSWER | 0.01 s | details |
| #3 | WRONG ANSWER | 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 stream
std::cin >> word;
//set validity-boolean to true
b = true;
//A word with even number of specific characters can't have an odd length
if(word.length() % 2 == 0) {
for(std::string::const_iterator it = word.begin(); it != word.end(); ++it)
if(!ocs[*it])
//add character occurence to map
ocs.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 false
b = false;
if(b)
++sum_of_even_words;
}
}
std::cout << sum_of_even_words << std::endl;
return 0;
}
Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 1000 korvata sopimusaika nuhatartunta korttiautomaatti ... |
| correct output |
|---|
| 15 |
| user output |
|---|
| 504 |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 1000 pub hansikaslokero erikoisvalmisteinen unijukka ... |
| correct output |
|---|
| 42 |
| user output |
|---|
| 504 |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000 haapalastu toipumisaika mustalaiskieli taidelainaamo ... |
| correct output |
|---|
| 70 |
| user output |
|---|
| 552 |
