| Task: | Ruudukko | 
| Sender: | Septicuss | 
| Submission time: | 2022-11-01 23:52:20 +0200 | 
| Language: | Java | 
| Status: | READY | 
| Result: | 0 | 
| group | verdict | score | 
|---|---|---|
| #1 | RUNTIME ERROR | 0 | 
| #2 | RUNTIME ERROR | 0 | 
| #3 | RUNTIME ERROR | 0 | 
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | RUNTIME ERROR | 0.07 s | 1, 2, 3 | details | 
| #2 | RUNTIME ERROR | 0.07 s | 1, 2, 3 | details | 
| #3 | RUNTIME ERROR | 0.07 s | 1, 2, 3 | details | 
| #4 | RUNTIME ERROR | 0.07 s | 2, 3 | details | 
| #5 | RUNTIME ERROR | 0.07 s | 2, 3 | details | 
| #6 | RUNTIME ERROR | 0.07 s | 2, 3 | details | 
| #7 | RUNTIME ERROR | 0.07 s | 3 | details | 
| #8 | RUNTIME ERROR | 0.07 s | 3 | details | 
| #9 | RUNTIME ERROR | 0.07 s | 3 | details | 
Code
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;
public class D4301 {
	static final long mod = 1000000007;
	static int n;
	static long c = 0;
	static long[][] grid;
	static long[][] dp;
	public static void main(String[] args) throws FileNotFoundException {
		long start = System.currentTimeMillis();
		FastReader reader = new FastReader(new FileInputStream(new File("C:/Users/vbala/Desktop/text.txt")));
		PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
		n = reader.nextInt();
		grid = new long[n][n];
		dp = new long[n][n];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++) {
				grid[i][j] = reader.nextLong();
			}
		reader.close();
		System.out.println("Read in " + (System.currentTimeMillis() - start) + " ms");
		c += n * n;
		for (int y = n-1; y > -1; y--)
			for (int x = n - 1; x > -1; x--) {
				if (grid[y][x] == 1) {
					dp[y][x] = 1;
					continue;
				}
				c += (sumFrom(y, x)) % mod;
			}
		if (c == 0) c = 1;
		writer.println(c);
		System.out.println("Solved in " + (System.currentTimeMillis() - start) + " ms");
		writer.flush();
		writer.close();
	}
	static long sumFrom(int y, int x) {
		if (dp[y][x] != 0) return dp[y][x];
		long value = grid[y][x];
		long sum = 0;
		for (int i = 0; i < n; i++) {
			long horizontal = grid[y][i];
			long vertical = grid[i][x];
			
			if (vertical < value) {
				if (vertical == 1) {
					sum += 1;
				} else {
					sum += (sumFrom(i, x) + 1);
				}
			}
			if (horizontal < value) {
				if (horizontal == 1) {
					sum += 1;
				} else {
					sum += (sumFrom(y, i) + 1);
				}
			}
		}
		dp[y][x] = sum;
		return sum;
	}
	static class FastReader {
		private BufferedReader br;
		private StringTokenizer st;
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		void close() {
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			st = null;
			br = null;
		}
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		BigInteger nextBigInteger() {
			return new BigInteger(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}Test details
Test 1
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input | 
|---|
| 3 1 1 1 1 1 1 1 1 1  | 
| correct output | 
|---|
| 9 | 
| user output | 
|---|
| (empty) | 
Error:
Exception in thread "main" java.io.FileNotFoundException: C:/Users/vbala/Desktop/text.txt...
Test 2
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input | 
|---|
| 3 1 2 3 6 5 4 7 8 9  | 
| correct output | 
|---|
| 135 | 
| user output | 
|---|
| (empty) | 
Error:
Exception in thread "main" java.io.FileNotFoundException: C:/Users/vbala/Desktop/text.txt...
Test 3
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input | 
|---|
| 3 7 8 1 4 5 4 3 9 6  | 
| correct output | 
|---|
| 57 | 
| user output | 
|---|
| (empty) | 
Error:
Exception in thread "main" java.io.FileNotFoundException: C:/Users/vbala/Desktop/text.txt...
Test 4
Group: 2, 3
Verdict: RUNTIME ERROR
| input | 
|---|
| 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...  | 
| correct output | 
|---|
| 10000 | 
| user output | 
|---|
| (empty) | 
Error:
Exception in thread "main" java.io.FileNotFoundException: C:/Users/vbala/Desktop/text.txt...
Test 5
Group: 2, 3
Verdict: RUNTIME ERROR
| input | 
|---|
| 100 1 2 3 4 5 6 7 8 9 10 11 12 13 ...  | 
| correct output | 
|---|
| 187458477 | 
| user output | 
|---|
| (empty) | 
Error:
Exception in thread "main" java.io.FileNotFoundException: C:/Users/vbala/Desktop/text.txt...
Test 6
Group: 2, 3
Verdict: RUNTIME ERROR
| input | 
|---|
| 100 2995 8734 1018 2513 7971 5063 ...  | 
| correct output | 
|---|
| 964692694 | 
| user output | 
|---|
| (empty) | 
Error:
Exception in thread "main" java.io.FileNotFoundException: C:/Users/vbala/Desktop/text.txt...
Test 7
Group: 3
Verdict: RUNTIME ERROR
| input | 
|---|
| 1000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...  | 
| correct output | 
|---|
| 1000000 | 
| user output | 
|---|
| (empty) | 
Error:
Exception in thread "main" java.io.FileNotFoundException: C:/Users/vbala/Desktop/text.txt...
Test 8
Group: 3
Verdict: RUNTIME ERROR
| input | 
|---|
| 1000 1 2 3 4 5 6 7 8 9 10 11 12 13 ...  | 
| correct output | 
|---|
| 229147081 | 
| user output | 
|---|
| (empty) | 
Error:
Exception in thread "main" java.io.FileNotFoundException: C:/Users/vbala/Desktop/text.txt...
Test 9
Group: 3
Verdict: RUNTIME ERROR
| input | 
|---|
| 1000 520283 805991 492643 75254 527...  | 
| correct output | 
|---|
| 951147313 | 
| user output | 
|---|
| (empty) | 
Error:
Exception in thread "main" java.io.FileNotFoundException: C:/Users/vbala/Desktop/text.txt...
