Code Submission Evaluation System Login

HIIT Open 2018

Start:2018-05-26 11:00:00
End:2018-05-26 16:00:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2018 - Results
History
2018-05-26 15:58:32
2018-05-26 15:42:41
Task:Find a Word
Sender:El Numero Uno
Submission time:2018-05-26 15:58:32
Language:Java
Status:READY
Result:RUNTIME ERROR

Test results

testverdicttime (s)
#1ACCEPTED0.38 / 1.00details
#2ACCEPTED0.33 / 1.00details
#3ACCEPTED0.34 / 1.00details
#4ACCEPTED0.32 / 1.00details
#5ACCEPTED0.34 / 1.00details
#6ACCEPTED0.31 / 1.00details
#7ACCEPTED0.29 / 1.00details
#8ACCEPTED0.33 / 1.00details
#9ACCEPTED0.34 / 1.00details
#10ACCEPTED0.32 / 1.00details
#11ACCEPTED0.34 / 1.00details
#12RUNTIME ERROR0.27 / 1.00details
#13RUNTIME ERROR0.22 / 1.00details
#14WRONG ANSWER0.34 / 1.00details
#15RUNTIME ERROR0.24 / 1.00details
#16RUNTIME ERROR0.22 / 1.00details

Code

import java.util.*;

class Coord {
	int x;
	int y;
	public Coord(int x, int y) {
		this.x = x;
		this.y=y;
	}
}

public class f {
	static int k;
	static List<String> finalStrings = new ArrayList<>();
	private static List<Coord> getSurroundings(Coord coord, List<List<Character>> matrix) {
		Coord coord1 = null;
		Coord coord2 = null;
		if (coord.x+1 <= matrix.size()-1) {
			coord1 = new Coord(coord.x+1, coord.y);
		}
		if (coord.y+1 <= matrix.size()-1) {
			coord2 = new Coord(coord.x, coord.y+1);
		}
		if (coord1 == null && coord2 == null) {
			return Arrays.asList();
			}
		if (coord1 == null) return Arrays.asList(coord2);
		if (coord2 == null) return Arrays.asList(coord1);
		if (matrix.get(coord1.x).get(coord1.y) < matrix.get(coord2.x).get(coord2.y)) {
			return Arrays.asList(coord1, coord2);
		}
		return Arrays.asList(coord2, coord1);
	}
	
	private static void solve(List<List<Character>> matrix, Coord coord, String currentString) {
		List<Coord> surroundings = getSurroundings(coord, matrix);
		if (surroundings.isEmpty()) {
			finalStrings.add(currentString);
			if (finalStrings.size() >= k) {
				System.out.println(finalStrings.get(k-1));
				System.exit(0);
			}
		}
		List<String> strings = new ArrayList<>();
		for (Coord c : surroundings) {
			String newString = currentString + String.valueOf(matrix.get(c.x).get(c.y));
			solve(matrix, c, newString);
		}
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a=0;
		
		if (in.hasNextLine()) {
			String line = in.nextLine();
			String[] dimensions = line.split(" ");
			a = Integer.parseInt(dimensions[0]);
			k = Integer.parseInt(dimensions[1]);
		}
		List<List<Character>> matrix = new ArrayList<>();
		for (int i = 0; i < a && in.hasNextLine(); i++) {
			String line = in.nextLine();
			char[] charArray = line.toCharArray();
			List<Character> lineList = new ArrayList<>();
			for (char c : charArray) {
				lineList.add(c);
			}
			matrix.add(lineList);
		}
		solve(matrix,new Coord(0,0), String.valueOf(matrix.get(0).get(0)));
	}

}

Test details

Test 1

Verdict: ACCEPTED

input
4 1
AAAA
AAAA
AAAA
AAAA
view   save

correct output
AAAAAAA
view   save

user output
AAAAAAA
view   save

Test 2

Verdict: ACCEPTED

input
4 2
AAAA
AAAA
AAAA
AAAA
view   save

correct output
AAAAAAA
view   save

user output
AAAAAAA
view   save

Test 3

Verdict: ACCEPTED

input
4 10
AAAA
AAAA
AAAA
AAAA
view   save

correct output
AAAAAAA
view   save

user output
AAAAAAA
view   save

Test 4

Verdict: ACCEPTED

input
4 19
AAAA
AAAA
AAAA
AAAA
view   save

correct output
AAAAAAA
view   save

user output
AAAAAAA
view   save

Test 5

Verdict: ACCEPTED

input
4 20
AAAA
AAAA
AAAA
AAAA
view   save

correct output
AAAAAAA
view   save

user output
AAAAAAA
view   save

Test 6

Verdict: ACCEPTED

input
4 1
QNJP
EVJU
XHZF
RXCV
view   save

correct output
QEVHXCV
view   save

user output
QEVHXCV
view   save

Test 7

Verdict: ACCEPTED

input
4 2
QNJP
EVJU
XHZF
RXCV
view   save

correct output
QEVHZCV
view   save

user output
QEVHZCV
view   save

Test 8

Verdict: ACCEPTED

input
4 10
QNJP
EVJU
XHZF
RXCV
view   save

correct output
QEXRXCV
view   save

user output
QEXRXCV
view   save

Test 9

Verdict: ACCEPTED

input
4 19
QNJP
EVJU
XHZF
RXCV
view   save

correct output
QNVJZCV
view   save

user output
QNVJZCV
view   save

Test 10

Verdict: ACCEPTED

input
4 20
QNJP
EVJU
XHZF
RXCV
view   save

correct output
QNVJZFV
view   save

user output
QNVJZFV
view   save

Test 11

Verdict: ACCEPTED

input
30 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
...
view   save

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
view   save

user output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
view   save

Test 12

Verdict: RUNTIME ERROR

input
30 15033633249770520
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
...
view   save

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
view   save

user output
(no output)
view   save

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "15033633249770520"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Integer.parseInt(Integer.java:652)
	at java.base/java.lang.Integer.parseInt(Integer.java:770)
	at f.main(f.java:59)

Test 13

Verdict: RUNTIME ERROR

input
30 30067266499541040
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
...
view   save

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
view   save

user output
(no output)
view   save

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "30067266499541040"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Integer.parseInt(Integer.java:652)
	at java.base/java.lang.Integer.parseInt(Integer.java:770)
	at f.main(f.java:59)

Test 14

Verdict: WRONG ANSWER

input
30 1
QNJPEVJUXHZFRXCVKBSJKUURVPLYUI
RXLGFBNQPBKQQRQFHLXUIUPLUOUOQW
FZNNUBMTLXUMTSJOOGBDBEVEYVWOLP
WYLTEQJBJRPSEMPOESVKFTQKEMSIAP
QHYOUWFHLJQDVTGVCSIVHNPKDWNJQC
GBUFNYPCWYNPQQMADZXQPYTAUETQSU
LURTALUCESXQWEFCOXPGXBFUIOMFBW
RJPAYRYBOCQKHOHRAWHJTITBTBTUQK
EMREBEZQUEFPCFEAYNTCYIBSMVIUPI
SCOSBRKAKZBPLLZPPOYCZRUTADFQEF
VKIJFVWGOCYMDCFXSEBAGJIRSKNYSK
FEVSYNRBXCOHWXGIRQOPNAIVYLXQOE
JNABESJIUMPKLSDJKBIGOSGCEJKNRN
SYROUHKKNTCYGDSSTYBQBYPOWUQIHS
YXZKTSAPWXLKLQGSNKTPGEAQIAHFMC
BAGQPHLNARILPPVQUYQOMTHOXNIKMZ
NLDRZQIWUYFGQXWCIQOCRXFUPKZWWY
AAROAOVNBBNVDZNZHOZGCHYAFTHHWD
DWCDSGBQZKLLXWHHWGXJQWNWENIZWZ
...
view   save

correct output
QNJLGFBBMJBHCCBOCEFBPLDCFGDJKB...
view   save

user output
QNJLGFBBMJBHCCBOCEFBPLDCFGDJKB...
view   save

Test 15

Verdict: RUNTIME ERROR

input
30 15033633249770520
QNJPEVJUXHZFRXCVKBSJKUURVPLYUI
RXLGFBNQPBKQQRQFHLXUIUPLUOUOQW
FZNNUBMTLXUMTSJOOGBDBEVEYVWOLP
WYLTEQJBJRPSEMPOESVKFTQKEMSIAP
QHYOUWFHLJQDVTGVCSIVHNPKDWNJQC
GBUFNYPCWYNPQQMADZXQPYTAUETQSU
LURTALUCESXQWEFCOXPGXBFUIOMFBW
RJPAYRYBOCQKHOHRAWHJTITBTBTUQK
EMREBEZQUEFPCFEAYNTCYIBSMVIUPI
SCOSBRKAKZBPLLZPPOYCZRUTADFQEF
VKIJFVWGOCYMDCFXSEBAGJIRSKNYSK
FEVSYNRBXCOHWXGIRQOPNAIVYLXQOE
JNABESJIUMPKLSDJKBIGOSGCEJKNRN
SYROUHKKNTCYGDSSTYBQBYPOWUQIHS
YXZKTSAPWXLKLQGSNKTPGEAQIAHFMC
BAGQPHLNARILPPVQUYQOMTHOXNIKMZ
NLDRZQIWUYFGQXWCIQOCRXFUPKZWWY
AAROAOVNBBNVDZNZHOZGCHYAFTHHWD
DWCDSGBQZKLLXWHHWGXJQWNWENIZWZ
...
view   save

correct output
QNXZYLYURTAYRYZQUKZCYOPKYKLQPX...
view   save

user output
(no output)
view   save

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "15033633249770520"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Integer.parseInt(Integer.java:652)
	at java.base/java.lang.Integer.parseInt(Integer.java:770)
	at f.main(f.java:59)

Test 16

Verdict: RUNTIME ERROR

input
30 30067266499541040
QNJPEVJUXHZFRXCVKBSJKUURVPLYUI
RXLGFBNQPBKQQRQFHLXUIUPLUOUOQW
FZNNUBMTLXUMTSJOOGBDBEVEYVWOLP
WYLTEQJBJRPSEMPOESVKFTQKEMSIAP
QHYOUWFHLJQDVTGVCSIVHNPKDWNJQC
GBUFNYPCWYNPQQMADZXQPYTAUETQSU
LURTALUCESXQWEFCOXPGXBFUIOMFBW
RJPAYRYBOCQKHOHRAWHJTITBTBTUQK
EMREBEZQUEFPCFEAYNTCYIBSMVIUPI
SCOSBRKAKZBPLLZPPOYCZRUTADFQEF
VKIJFVWGOCYMDCFXSEBAGJIRSKNYSK
FEVSYNRBXCOHWXGIRQOPNAIVYLXQOE
JNABESJIUMPKLSDJKBIGOSGCEJKNRN
SYROUHKKNTCYGDSSTYBQBYPOWUQIHS
YXZKTSAPWXLKLQGSNKTPGEAQIAHFMC
BAGQPHLNARILPPVQUYQOMTHOXNIKMZ
NLDRZQIWUYFGQXWCIQOCRXFUPKZWWY
AAROAOVNBBNVDZNZHOZGCHYAFTHHWD
DWCDSGBQZKLLXWHHWGXJQWNWENIZWZ
...
view   save

correct output
QRXZYLYURTAYRYZQUKZCYOPKYKLQPX...
view   save

user output
(no output)
view   save

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "30067266499541040"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Integer.parseInt(Integer.java:652)
	at java.base/java.lang.Integer.parseInt(Integer.java:770)
	at f.main(f.java:59)