Task: | Find a Word |
Sender: | DROP TABLE |
Submission time: | 2018-05-26 15:39:31 +0300 |
Language: | Java |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.32 s | details |
#2 | ACCEPTED | 0.33 s | details |
#3 | ACCEPTED | 0.38 s | details |
#4 | ACCEPTED | 0.37 s | details |
#5 | ACCEPTED | 0.36 s | details |
#6 | ACCEPTED | 0.38 s | details |
#7 | ACCEPTED | 0.34 s | details |
#8 | ACCEPTED | 0.33 s | details |
#9 | ACCEPTED | 0.32 s | details |
#10 | ACCEPTED | 0.37 s | details |
#11 | TIME LIMIT EXCEEDED | -- | details |
#12 | RUNTIME ERROR | 0.22 s | details |
#13 | RUNTIME ERROR | 0.24 s | details |
#14 | TIME LIMIT EXCEEDED | -- | details |
#15 | RUNTIME ERROR | 0.25 s | details |
#16 | RUNTIME ERROR | 0.22 s | details |
Code
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main2 { static List<String> WORDS = new ArrayList<>(); static int n; static int k; static Scanner scanner = new Scanner(System.in); static char[][] table; public static void rec(int y, int x){ String s = ""; s += table[y][x]; if (y == n - 1 && x == n - 1){ WORDS.add(s); return; } if(x < n - 1) { rec(y, x + 1, s); } if(y < n - 1) { rec(y + 1, x, s); } } public static void rec(int y, int x, String s){ s += table[y][x]; if (y == n - 1 && x == n - 1){ WORDS.add(s); return; } if(x < n - 1) { rec(y, x + 1, s); } if(y < n - 1) { rec(y + 1, x, s); } } public static void main(String[] args) { n = scanner.nextInt(); k = scanner.nextInt(); table = new char[n][n]; for(int i = 0; i < n; i++){ table[i] = scanner.next().toCharArray(); } rec(0,0); WORDS.sort(null); //System.out.println(WORDS); System.out.println(WORDS.get(k-1)); } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
4 1 AAAA AAAA AAAA AAAA |
correct output |
---|
AAAAAAA |
user output |
---|
AAAAAAA |
Test 2
Verdict: ACCEPTED
input |
---|
4 2 AAAA AAAA AAAA AAAA |
correct output |
---|
AAAAAAA |
user output |
---|
AAAAAAA |
Test 3
Verdict: ACCEPTED
input |
---|
4 10 AAAA AAAA AAAA AAAA |
correct output |
---|
AAAAAAA |
user output |
---|
AAAAAAA |
Test 4
Verdict: ACCEPTED
input |
---|
4 19 AAAA AAAA AAAA AAAA |
correct output |
---|
AAAAAAA |
user output |
---|
AAAAAAA |
Test 5
Verdict: ACCEPTED
input |
---|
4 20 AAAA AAAA AAAA AAAA |
correct output |
---|
AAAAAAA |
user output |
---|
AAAAAAA |
Test 6
Verdict: ACCEPTED
input |
---|
4 1 QNJP EVJU XHZF RXCV |
correct output |
---|
QEVHXCV |
user output |
---|
QEVHXCV |
Test 7
Verdict: ACCEPTED
input |
---|
4 2 QNJP EVJU XHZF RXCV |
correct output |
---|
QEVHZCV |
user output |
---|
QEVHZCV |
Test 8
Verdict: ACCEPTED
input |
---|
4 10 QNJP EVJU XHZF RXCV |
correct output |
---|
QEXRXCV |
user output |
---|
QEXRXCV |
Test 9
Verdict: ACCEPTED
input |
---|
4 19 QNJP EVJU XHZF RXCV |
correct output |
---|
QNVJZCV |
user output |
---|
QNVJZCV |
Test 10
Verdict: ACCEPTED
input |
---|
4 20 QNJP EVJU XHZF RXCV |
correct output |
---|
QNVJZFV |
user output |
---|
QNVJZFV |
Test 11
Verdict: TIME LIMIT EXCEEDED
input |
---|
30 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ... |
correct output |
---|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
user output |
---|
(empty) |
Test 12
Verdict: RUNTIME ERROR
input |
---|
30 15033633249770520 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ... |
correct output |
---|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.util.InputMismatchException: For input string: "15033633249770520" at java.base/java.util.Scanner.nextInt(Scanner.java:2264) at java.base/java.util.Scanner.nextInt(Scanner.java:2212) at Main2.main(Main2.java:45)
Test 13
Verdict: RUNTIME ERROR
input |
---|
30 30067266499541040 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ... |
correct output |
---|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.util.InputMismatchException: For input string: "30067266499541040" at java.base/java.util.Scanner.nextInt(Scanner.java:2264) at java.base/java.util.Scanner.nextInt(Scanner.java:2212) at Main2.main(Main2.java:45)
Test 14
Verdict: TIME LIMIT EXCEEDED
input |
---|
30 1 QNJPEVJUXHZFRXCVKBSJKUURVPLYUI RXLGFBNQPBKQQRQFHLXUIUPLUOUOQW FZNNUBMTLXUMTSJOOGBDBEVEYVWOLP WYLTEQJBJRPSEMPOESVKFTQKEMSIAP ... |
correct output |
---|
QNJLGFBBMJBHCCBOCEFBPLDCFGDJKB... |
user output |
---|
(empty) |
Test 15
Verdict: RUNTIME ERROR
input |
---|
30 15033633249770520 QNJPEVJUXHZFRXCVKBSJKUURVPLYUI RXLGFBNQPBKQQRQFHLXUIUPLUOUOQW FZNNUBMTLXUMTSJOOGBDBEVEYVWOLP WYLTEQJBJRPSEMPOESVKFTQKEMSIAP ... |
correct output |
---|
QNXZYLYURTAYRYZQUKZCYOPKYKLQPX... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.util.InputMismatchException: For input string: "15033633249770520" at java.base/java.util.Scanner.nextInt(Scanner.java:2264) at java.base/java.util.Scanner.nextInt(Scanner.java:2212) at Main2.main(Main2.java:45)
Test 16
Verdict: RUNTIME ERROR
input |
---|
30 30067266499541040 QNJPEVJUXHZFRXCVKBSJKUURVPLYUI RXLGFBNQPBKQQRQFHLXUIUPLUOUOQW FZNNUBMTLXUMTSJOOGBDBEVEYVWOLP WYLTEQJBJRPSEMPOESVKFTQKEMSIAP ... |
correct output |
---|
QRXZYLYURTAYRYZQUKZCYOPKYKLQPX... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.util.InputMismatchException: For input string: "30067266499541040" at java.base/java.util.Scanner.nextInt(Scanner.java:2264) at java.base/java.util.Scanner.nextInt(Scanner.java:2212) at Main2.main(Main2.java:45)