Task: | Alphabet Accumulation |
Sender: | madwarge |
Submission time: | 2018-09-20 18:11:09 +0300 |
Language: | Java |
Status: | READY |
Result: | RUNTIME ERROR |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.22 s | details |
#2 | ACCEPTED | 0.23 s | details |
#3 | ACCEPTED | 0.24 s | details |
#4 | RUNTIME ERROR | 0.30 s | details |
#5 | RUNTIME ERROR | 0.30 s | details |
#6 | TIME LIMIT EXCEEDED | -- | details |
#7 | RUNTIME ERROR | 0.30 s | details |
#8 | RUNTIME ERROR | 0.30 s | details |
#9 | RUNTIME ERROR | 0.30 s | details |
#10 | TIME LIMIT EXCEEDED | -- | 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(); 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.println(tieto + vastaukset[i]); tieto += vastaukset[i]; } } 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 ... |
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: RUNTIME ERROR
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:26)
Test 5
Verdict: RUNTIME ERROR
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:26)
Test 6
Verdict: TIME LIMIT EXCEEDED
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: RUNTIME ERROR
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:26)
Test 8
Verdict: RUNTIME ERROR
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:26)
Test 9
Verdict: RUNTIME ERROR
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:26)
Test 10
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 30488 rsrlsoassssrrsssrrrssrssrsrrss... |
correct output |
---|
1 2 2 2 2 4 5 5 5 5 5 5 5 5 5 ... |
user output |
---|
(empty) |