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

Compiler report

input/Ruudukko.java:22: error: incompatible types: int cannot be converted to Long
                arr2[i][j] = 1;
                             ^
input/Ruudukko.java:45: error: incompatible types: int cannot be converted to Long
        Long sum = 0;
                   ^
2 errors

Code

import java.util.Scanner;
import java.math.BigInteger;

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];
        Long[][] arr2 = new Long[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])%1000000007;
                            }
                        }
                        for(int l = 0; l < n; l++) {
                            if(arr[l][k] < i) {
                                arr2[j][k] = (arr2[j][k] + arr2[l][k])%1000000007;
                            }
                        }
                    }
                }
            }
        }

        Long sum = 0;

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

        System.out.print(sum);
    }
}