CSES - KILO 2018 3/5 - Results
Submission details
Task:Alphabet Accumulation
Sender:madwarge
Submission time:2018-09-20 18:27:38 +0300
Language:Java
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.27 sdetails
#2ACCEPTED0.27 sdetails
#3ACCEPTED0.28 sdetails
#40.30 sdetails
#50.30 sdetails
#6--details
#70.30 sdetails
#80.30 sdetails
#90.30 sdetails
#10--details

Code

//package alphabetaccumulation;


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();
        
        int vastaukset[] = new int[str.length()+1];
        
        //sanat läpi
        for (int i = 0; i < m; i++) {
            
            String sana = s.nextLine();
            for (int j = sana.length(); j <= str.length(); j++) {
                if(pystyyTekemaan(sana, str.substring(0, j))) {
                    vastaukset[j]++;
                    break;
                }
            }
            
        }
        
        int tieto = 0;
        for (int i = 1; i < vastaukset.length; i++) {
            System.out.print((tieto + vastaukset[i]) + " ");
            tieto += vastaukset[i];
        }
        System.out.print("\n");
    }
    
    public static boolean pystyyTekemaan(String sana, String substr) {
        int[] t = new int['z'];
        for (int p = 0; p < substr.length(); p++) {
            t[substr.charAt(p)]++;    
        }
        
        int[] t2 = new int['z'];
        for (int j = 0; j < sana.length(); j++) {
            t2[sana.charAt(j)]++;
            if(t2[sana.charAt(j)] > t[sana.charAt(j)]) {
                return false;
            }
        }
        return true;
    }
    
}

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 0 2 2 2 2 2 2 2 2 2 ...

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 3 3 3 3 4 4 4 29 29 ...

Test 4

Verdict:

input
100000 100000
yzxyzzyywyyzzyzwwzwytyzzyxxxyy...

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

user output
(empty)

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

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)

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

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.pystyyTekemaan(AlphabetAccumulation.java:44)
	at AlphabetAccumulation.main(AlphabetAccumulation.java:25)

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.pystyyTekemaan(AlphabetAccumulation.java:44)
	at AlphabetAccumulation.main(AlphabetAccumulation.java:25)

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.pystyyTekemaan(AlphabetAccumulation.java:44)
	at AlphabetAccumulation.main(AlphabetAccumulation.java:25)

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)