CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:Affax
Submission time:2019-09-30 15:47:29 +0300
Language:Java
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.13 sdetails
#2ACCEPTED0.12 sdetails
#30.12 sdetails
#40.13 sdetails
#50.14 sdetails
#60.15 sdetails

Code

import java.util.Scanner;
import java.util.logging.Logger;

public class Tehtava1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int input = scanner.nextInt();
        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) {
        System.out.println(msg);
    }
}

Test details

Test 1

Verdict: ACCEPTED

input
1

correct output

user output

Test 2

Verdict: ACCEPTED

input
2

correct output
1 2 
2 1 

user output
1 2 
2 1 

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
1 5 4 3 2 
2 1 5 4 3 
3 2 1 5 4 
4 3 2 1 5 
5 4 3 2 1 

Test 4

Verdict:

input
42

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

user output
1 42 41 40 39 38 37 36 35 34 3...
Truncated

Test 5

Verdict:

input
99

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

user output
1 99 98 97 96 95 94 93 92 91 9...
Truncated

Test 6

Verdict:

input
100

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

user output
1 100 99 98 97 96 95 94 93 92 ...
Truncated