CSES - Datatähti 2021 alku - Results
Submission details
Task:Sanalista
Sender:iRobo
Submission time:2020-10-10 14:59:49 +0300
Language:Java
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.17 sdetails
#2ACCEPTED0.17 sdetails
#3ACCEPTED0.17 sdetails

Code

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int lineCount = input.nextInt();

        String stringInput;
        int noOfSatisfyingWords = 0;

        for(int i = 0; i < lineCount; i++) {
            stringInput = input.next();
            if(checkWordPairsOfLetters(stringInput)) {
                noOfSatisfyingWords++;
            }
        }

        System.out.println(noOfSatisfyingWords);
    }

    public static boolean checkWordPairsOfLetters(String word) {
        boolean paired = true;
        int[] letters = new int[27];
        for(int i = 0; i < word.length(); i++) {
            //97 = a, 122 = z
            letters[(int)word.charAt(i)-97]++;
        }
        for(int i = 0; i < 27; i++) {
            if(letters[i] % 2 == 1) {
                paired = false;
                break;
            }
        }
        return paired;
    }
}

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