CSES - KILO 2018 3/5 - Results
Submission details
Task:Alphabet Accumulation
Sender:madwarge
Submission time:2018-09-20 17:46:53 +0300
Language:Java
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.21 sdetails
#2ACCEPTED0.23 sdetails
#3ACCEPTED0.24 sdetails
#4--details
#5--details
#6--details
#70.40 sdetails
#81.67 sdetails
#91.69 sdetails
#10--details

Code

//package alphabetaccumulation;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class AlphabetAccumulation {


    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        
        s.nextLine();
        String str = s.nextLine();
        
        
        List<String> lista = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            lista.add(s.nextLine());
        }
        
        int tieto = 0;
        
        for (int i = 1; i <= n; i++) {
            int[] t = new int['z'];
            for (int p = 0; p < i; p++) {
                t[str.charAt(p)]++;    
            }
            
            int summa = 0;
            
            for (String string : lista) {
                int[] t2 = new int['z'];
                for (int j = 0; j < string.length(); j++) {
                    t2[string.charAt(j)]++;
                    if(t2[string.charAt(j)] > t[string.charAt(j)]) {
                        summa--;
                        break;
                    }
                }
                summa++;
            }
            System.out.println(summa);
        }
    }
    
}

Test details

Test 1

Verdict: ACCEPTED

input
3 3
aab
aa
ba
bb

correct output
0 1 2 

user output
0
1
2

Test 2

Verdict: ACCEPTED

input
100 10
facdeebdaeffeadfdccgecbbegfdff...

correct output
0 0 0 0 0 0 2 2 2 2 2 2 2 2 2 ...

user output
0
0
0
0
0
...

Test 3

Verdict: ACCEPTED

input
100 50
gggggfgggfggeggeggafgfffgggfgg...

correct output
0 0 0 0 0 3 3 3 3 4 4 4 29 29 ...

user output
0
0
0
0
0
...

Test 4

Verdict:

input
100000 100000
yzxyzzyywyyzzyzwwzwytyzzyxxxyy...

correct output
17 18 18 18 18 18 18 18 2197 2...

user output
(empty)

Test 5

Verdict:

input
100000 100000
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...

correct output
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

user output
(empty)

Test 6

Verdict:

input
100000 20
ccacccbaccccacacacacaaacaccccc...

correct output
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

user output
(empty)

Test 7

Verdict:

input
100000 20
rypyjiljrkjrhsbohtbvacxnfyucvi...

correct output
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

user output
(empty)

Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 122
	at AlphabetAccumulation.main(AlphabetAccumulation.java:38)

Test 8

Verdict:

input
100000 32258
ztixcicqghqttowabnxvulwngxzpsm...

correct output
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

user output
(empty)

Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 122
	at AlphabetAccumulation.main(AlphabetAccumulation.java:30)

Test 9

Verdict:

input
100000 32258
zzzyzzzzzzzzzzzyzzzzzzzzzzzyzz...

correct output
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

user output
(empty)

Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 122
	at AlphabetAccumulation.main(AlphabetAccumulation.java:30)

Test 10

Verdict:

input
100000 30488
rsrlsoassssrrsssrrrssrssrsrrss...

correct output
1 2 2 2 2 4 5 5 5 5 5 5 5 5 5 ...

user output
(empty)