CSES - Datatähti 2023 alku - Results
Submission details
Task:Ruudukko
Sender:lompakkomies
Submission time:2022-11-01 12:00:48 +0200
Language:Java
Status:COMPILE ERROR

Compiler report

input/Ruudukko.java:53: error: reached end of file while parsing
}
 ^
1 error

Code

import java.util.Scanner;

public class Ruudukko {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();

        int[][] arr = new int[n][n];
        int[][] arr2 = new int[n][n];

        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                arr[i][j] = scan.nextInt();
            }
        }

        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                arr2[i][j] = 1;
            }
        }

        for(int i = 2; i <= n*n; i++) {
            for(int j = 0; j < n; j++) {
                for(int k = 0; k < n; k++) {
                    if(arr[j][k] == i) {
                        for(int l = 0; l < n; l++) {
                            if(arr[j][l] < i) {
                                arr2[j][k] = arr2[j][k] + arr2[j][l];
                            }
                        }
                        for(int l = 0; l < n; l++) {
                            if(arr[l][k] < i) {
                                arr2[j][k] = arr2[j][k] + arr2[l][k];
                            }
                        }
                    }
                }
            }
        }

        int sum = 0;

        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                sum = sum + arr2[i][j];
        }

        System.out.print(sum);
    }
}