CSES - Datatähti 2021 alku - Results
Submission details
Task:Sanalista
Sender:_Ahrou
Submission time:2020-09-28 16:34:08 +0300
Language:C++ (C++11)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.01 sdetails

Compiler report

input/code.cpp:9:12: warning: multi-character character constant [-Wmultichar]
   if (c == 'ä')
            ^~~~
input/code.cpp:11:17: warning: multi-character character constant [-Wmultichar]
   else if (c == 'ö')
                 ^~~~
input/code.cpp:13:17: warning: multi-character character constant [-Wmultichar]
   else if (c == 'å')
                 ^~~~

Code

#include <iostream>
#include <string>

int all_even(const std::string& word)
{
	int chars[29] = { 0 };
	for (auto c : word)
	{
		if (c == 'ä')
			chars[26]++;
		else if (c == 'ö')
			chars[27]++;
		else if (c == 'å')
			chars[28]++;
		else
		{
			if (c > 96)
				chars[c-'a']++;
			else
				chars[c-'A']++;
		}
	}
	for (int i = 0; i < 29; i++)
	{
		if (chars[i] % 2 != 0)
		{
			return 0;
		}
	}
	return 1;
}

int main()
{
	int n_words;
	int n_even_nums = 0;
	std::string line;
	std::getline(std::cin, line);

	n_words = std::stoi(line);
	for (int i = 0; i < n_words; i++)
	{
		std::getline(std::cin, line);
		n_even_nums += all_even(line);
	}
	std::cout << n_even_nums;
	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