Task: | Sanalista |
Sender: | anton7r |
Submission time: | 2020-10-09 21:45:56 +0300 |
Language: | Java |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.10 s | details |
#2 | ACCEPTED | 0.10 s | details |
#3 | ACCEPTED | 0.10 s | details |
Code
import java.io.*; import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] args) { int rivienMaara; String merkkijono; int pituus; int parilliset = 0; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { rivienMaara = Integer.parseInt(br.readLine()); for (int i = 0; i < rivienMaara; i++) { merkkijono = br.readLine().trim(); pituus = merkkijono.length(); if(pituus % 2 == 0) { Map<Character, Integer> merkkienMaarat = new HashMap<>(); for (int j = 0; j < pituus; j++) { final char merkki = merkkijono.charAt(j); Integer merkinMaara = merkkienMaarat.get(merkki); if(merkinMaara == null) { merkinMaara = 0; } merkkienMaarat.put(merkki, merkinMaara + 1); } Boolean onkoOk = true; for (Character k : merkkienMaarat.keySet()) { if(merkkienMaarat.get(k) % 2 != 0) { onkoOk = false; break; } } if(onkoOk) parilliset++; } } System.out.print(parilliset); } catch (IOException ioe) { System.out.println(ioe); } } }
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 |