CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:Jiahao
Submission time:2020-10-01 11:51:17 +0300
Language:Java
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1--1, 2, 3details
#2--1, 2, 3details
#3--1, 2, 3details
#4--1, 2, 3details
#5--1, 2, 3details
#6--1, 2, 3details
#7--1, 2, 3details
#8--2, 3details
#9--2, 3details
#10--2, 3details
#11--3details
#12--3details
#13--3details

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

input
100

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
(empty)