Task: | Ratsun reitit |
Sender: | Jiahao |
Submission time: | 2020-10-01 11:51:17 +0300 |
Language: | Java |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | TIME LIMIT EXCEEDED | 0 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
#2 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
#4 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
#5 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
#6 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
#7 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
#8 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#9 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#10 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#11 | TIME LIMIT EXCEEDED | -- | 3 | details |
#12 | TIME LIMIT EXCEEDED | -- | 3 | details |
#13 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
import java.util.Scanner; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; public class Ratsu { public static void main(String[] args) { Scanner lukija = new Scanner(System.in); int n = Integer.valueOf(lukija.nextLine()); Integer[][] lauta = new Integer[n][n]; for (int r = 0; r < n; r++) { for (int s = 0; s < n; s++) { lauta[r][s] = 0; } } HashMap<Integer, ArrayList<String>> ratkaistut = new HashMap<>(); ratkaistut.put(0, new ArrayList<>()); ratkaistut.get(0).add("0,0"); for (int i = 1; i < n * n; i++) { ArrayList<String> uudet = ratkaistut.get(i - 1); for (int k = 0; k < uudet.size(); k++) { int x = Integer.valueOf(uudet.get(k).split(",")[0]); int y = Integer.valueOf(uudet.get(k).split(",")[1]); int x1 = x - 2; int x2 = x - 1; int x3 = x + 1; int x4 = x + 2; int y1 = y + 2; int y2 = y + 1; int y3 = y - 1; int y4 = y - 2; if (x1 >= 0) { if (y2 < n) { Integer ruutu = lauta[x1][y2]; if (ruutu == 0) { ruutu = i; uudet.add(x1 + "," + y2); } } if (y3 >= 0) { Integer ruutu = lauta[x1][y3]; if (ruutu == 0) { ruutu = i; uudet.add(x1 + "," + y3); } } } if (x2 >= 0) { if (y1 < n) { Integer ruutu = lauta[x2][y1]; if (ruutu == 0) { ruutu = i; uudet.add(x2 + "," + y1); } } if (y4 >= 0) { Integer ruutu = lauta[x2][y4]; if (ruutu == 0) { ruutu = i; uudet.add(x2 + "," + y4); } } } if (x3 < n) { if (y1 < n) { Integer ruutu = lauta[x3][y1]; if (ruutu == 0) { ruutu = i; uudet.add(x3 + "," + y1); } } if (y4 >= 0) { Integer ruutu = lauta[x3][y4]; if (ruutu == 0) { ruutu = i; uudet.add(x3 + "," + y4); } } } if (x4 < n) { if (y2 < n) { Integer ruutu = lauta[x4][y2]; if (ruutu == 0) { ruutu = i; uudet.add(x4 + "," + y2); } } if (y3 >= 0) { Integer ruutu = lauta[x4][y3]; if (ruutu == 0) { ruutu = i; uudet.add(x4 + "," + y3); } } } } ratkaistut.put(i, uudet); } lauta[0][0] = 0; // Tulokset for (int r = 0; r < n; r++) { for (int s = 0; s < n; s++) { System.out.print(lauta[r][s]); if (s == n - 1) { System.out.println(); } else { System.out.print(" "); } } } } }
Test details
Test 1
Group: 1, 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
4 |
correct output |
---|
0 3 2 5 3 4 1 2 2 1 4 3 5 2 3 2 |
user output |
---|
(empty) |
Test 2
Group: 1, 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
5 |
correct output |
---|
0 3 2 3 2 3 4 1 2 3 2 1 4 3 2 3 2 3 2 3 2 3 2 3 4 |
user output |
---|
(empty) |
Test 3
Group: 1, 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
6 |
correct output |
---|
0 3 2 3 2 3 3 4 1 2 3 4 2 1 4 3 2 3 3 2 3 2 3 4 2 3 2 3 4 3 ... |
user output |
---|
(empty) |
Test 4
Group: 1, 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
7 |
correct output |
---|
0 3 2 3 2 3 4 3 4 1 2 3 4 3 2 1 4 3 2 3 4 3 2 3 2 3 4 3 2 3 2 3 4 3 4 ... |
user output |
---|
(empty) |
Test 5
Group: 1, 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
8 |
correct output |
---|
0 3 2 3 2 3 4 5 3 4 1 2 3 4 3 4 2 1 4 3 2 3 4 5 3 2 3 2 3 4 3 4 2 3 2 3 4 3 4 5 ... |
user output |
---|
(empty) |
Test 6
Group: 1, 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
9 |
correct output |
---|
0 3 2 3 2 3 4 5 4 3 4 1 2 3 4 3 4 5 2 1 4 3 2 3 4 5 4 3 2 3 2 3 4 3 4 5 2 3 2 3 4 3 4 5 4 ... |
user output |
---|
(empty) |
Test 7
Group: 1, 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
10 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 3 4 1 2 3 4 3 4 5 6 2 1 4 3 2 3 4 5 4 5 3 2 3 2 3 4 3 4 5 6 2 3 2 3 4 3 4 5 4 5 ... |
user output |
---|
(empty) |
Test 8
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
25 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
(empty) |
Test 9
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
49 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
(empty) |
Test 10
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
50 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
(empty) |
Test 11
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
75 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
(empty) |
Test 12
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
99 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
(empty) |
Test 13
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
(empty) |