CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:Affax
Submission time:2019-09-30 15:43:08 +0300
Language:Java
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.14 sdetails
#20.14 sdetails
#30.14 sdetails
#40.14 sdetails
#50.14 sdetails
#60.14 sdetails

Code

import java.util.logging.Logger;

public class Tehtava1 {
    private final static Logger LOGGER = Logger.getLogger("Affax");

    public static void main(String[] args) {
        int input = Integer.parseInt(args[0]);
        int inputM = input - 1;

        String[][] posses = new String[input][input];

        for (int y = 0; y < input; y++) {
            int left = y;
            int right = inputM - y;

            for (int x = 0; x < right; x++) {
                posses[y + 1 + x][y] = String.valueOf(x + 2);
            }

            for (int x = 0; x < left; x++) {
                posses[y - 1 - x][y] = String.valueOf(input - x);
            }

            posses[y][y] = "1";
        }

        StringBuilder realString = new StringBuilder();
        for (int y = 0; y < input; y++) {
            StringBuilder str = new StringBuilder();
            for (int x = 0; x < input; x++) {
                str.append(posses[y][x]).append(' ');
            }
            realString.append(sub(str.toString())).append(y == inputM ? "" : "\n");
        }

        log(realString.toString());
    }

    private static String sub(String str) {
        String string = str;
        string.substring(0, str.length());
        return string;
    }

    private static void log(String msg) {
        LOGGER.info(msg);
    }
}

Test details

Test 1

Verdict:

input
1

correct output

user output
(empty)

Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at Tehtava1.main(Tehtava1.java:7)

Test 2

Verdict:

input
2

correct output
1 2 
2 1 

user output
(empty)

Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at Tehtava1.main(Tehtava1.java:7)

Test 3

Verdict:

input
5

correct output
1 2 3 4 5 
2 1 4 3 6 
3 4 1 2 7 
4 3 2 1 8 
5 6 7 8 1 

user output
(empty)

Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at Tehtava1.main(Tehtava1.java:7)

Test 4

Verdict:

input
42

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at Tehtava1.main(Tehtava1.java:7)

Test 5

Verdict:

input
99

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at Tehtava1.main(Tehtava1.java:7)

Test 6

Verdict:

input
100

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at Tehtava1.main(Tehtava1.java:7)