CSES - Datatähti 2021 alku - Results
Submission details
Task:Sanalista
Sender:Jiahao
Submission time:2020-09-28 09:57:36 +0300
Language:Java
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.18 sdetails
#20.18 sdetails
#30.18 sdetails

Code

import java.util.ArrayList;
import java.util.Scanner;
import java.util.HashMap;

public class Sanalista {
    public static void main(String[] args) {
        Scanner lukija = new Scanner(System.in);
        ArrayList<String> sanat = new ArrayList<>();

        int n = Integer.valueOf(lukija.nextLine());

        for (int i = 0; i < n; i++) {
            String syote = lukija.nextLine();

            if (syote.length() % 2 == 0) {
                sanat.add(syote);
            }
        }

        for (String sana : sanat) {
            HashMap<Character, Integer> kirjaimet = new HashMap<>();

            for (int i = 0; i < sana.length(); i++) {
                Character kirjain = (Character) sana.charAt(i);
                if (kirjaimet.containsKey(kirjain)) {
                    kirjaimet.put(kirjain, 1);
                } else {
                    kirjaimet.put(kirjain, 2);
                }
                
            }

            if (kirjaimet.values().contains(1)) {
                sanat.remove(sana);
            }
        }

        System.out.println(sanat.size());
    }
}

Test details

Test 1

Verdict:

input
1000
korvata
sopimusaika
nuhatartunta
korttiautomaatti
...

correct output
15

user output
(empty)

Error:
Exception in thread "main" java.util.ConcurrentModificationException
	at java.base/java.ut...

Test 2

Verdict:

input
1000
pub
hansikaslokero
erikoisvalmisteinen
unijukka
...

correct output
42

user output
(empty)

Error:
Exception in thread "main" java.util.ConcurrentModificationException
	at java.base/java.ut...

Test 3

Verdict:

input
1000
haapalastu
toipumisaika
mustalaiskieli
taidelainaamo
...

correct output
70

user output
(empty)

Error:
Exception in thread "main" java.util.ConcurrentModificationException
	at java.base/java.ut...