Submission details
Task:Massive Matrices
Sender:thierry
Submission time:2018-09-13 18:31:28 +0300
Language:Java
Status:READY
Result:
Test results
testverdicttime
#10.14 sdetails
#20.15 sdetails
#30.15 sdetails
#40.16 sdetails
#50.15 sdetails
#60.15 sdetails
#70.15 sdetails
#80.14 sdetails
#90.14 sdetails
#100.14 sdetails
#110.14 sdetails
#120.14 sdetails
#130.14 sdetails
#140.14 sdetails
#150.14 sdetails
#160.14 sdetails
#170.15 sdetails
#180.14 sdetails
#190.14 sdetails
#200.14 sdetails
#210.14 sdetails
#220.14 sdetails
#230.54 sdetails
#240.54 sdetails
#250.53 sdetails
#260.54 sdetails
#270.53 sdetails
#280.52 sdetails
#290.53 sdetails
#300.53 sdetails
#310.53 sdetails
#320.53 sdetails
#330.53 sdetails

Code

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Viikko2e {

    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        // TODO code application logic here

        FastReader s = new FastReader();
        int n = s.nextInt();

        int[][] sudoku = new int[n][n];

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

        if (tarkista(n, sudoku)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }

    private static boolean tarkista(int n, int[][] sudoku) {
        Set<Integer> setti = new HashSet<>();
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; i < n; i++) {
                int a = sudoku[i][j];
                if (setti.contains(a)) {
                    return false;
                }
                setti.add(a);
            }
            setti.clear();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; i < n; i++) {
                int a = sudoku[j][i];
                if (setti.contains(a)) {
                    return false;
                }
                setti.add(a);
            }
        }
        return true;
    }
}

Test details

Test 1

Verdict:

input
10
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 2

Verdict:

input
10
10 10 10 10 10 10 10 10 10 10
0 0 0 0 0 0 0 0 0 0

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 3

Verdict:

input
10
0 0 0 0 0 0 0 0 0 0
10 10 10 10 10 10 10 10 10 10

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 4

Verdict:

input
10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10

correct output
100

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 5

Verdict:

input
10
3 4 4 4 5 5 6 10 10 10
0 0 0 0 0 0 0 0 0 0

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 6

Verdict:

input
10
0 3 4 5 6 6 7 7 7 7
10 10 10 10 10 10 10 10 10 10

correct output
90

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 7

Verdict:

input
10
0 0 0 0 0 0 0 0 0 0
0 0 2 3 7 8 9 10 10 10

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 8

Verdict:

input
10
10 10 10 10 10 10 10 10 10 10
1 4 4 5 5 5 5 7 9 9

correct output
90

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 9

Verdict:

input
10
1 2 5 5 5 5 6 6 10 10
0 0 3 5 6 7 7 7 7 10

correct output
58

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 10

Verdict:

input
10
0 0 0 1 1 1 2 4 6 8
0 1 1 1 4 4 4 4 4 5

correct output
10

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 11

Verdict:

input
10
2 4 4 4 5 5 6 6 8 9
0 0 0 1 1 2 7 7 8 10

correct output
24

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 12

Verdict:

input
100
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 13

Verdict:

input
100
100 100 100 100 100 100 100 10...

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 14

Verdict:

input
100
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 15

Verdict:

input
100
100 100 100 100 100 100 100 10...

correct output
10000

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 16

Verdict:

input
100
0 0 0 0 4 6 7 8 9 11 12 12 13 ...

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 17

Verdict:

input
100
0 0 3 5 6 6 8 8 8 10 14 15 15 ...

correct output
9800

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 18

Verdict:

input
100
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 19

Verdict:

input
100
100 100 100 100 100 100 100 10...

correct output
9400

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 20

Verdict:

input
100
2 3 5 5 7 9 9 11 11 11 11 15 1...

correct output
6080

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 21

Verdict:

input
100
1 2 2 3 6 6 6 6 8 11 12 12 12 ...

correct output
5154

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 22

Verdict:

input
100
0 0 3 3 3 4 4 5 6 8 9 9 11 11 ...

correct output
4813

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at java.base/java.util.StringTo...

Test 23

Verdict:

input
200000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at Viikko2e.main(V...

Test 24

Verdict:

input
200000
200000 200000 200000 200000 20...

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at Viikko2e.main(V...

Test 25

Verdict:

input
200000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at Viikko2e.main(V...

Test 26

Verdict:

input
200000
200000 200000 200000 200000 20...

correct output
40000000000

user output
(empty)

Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at Viikko2e.main(V...

Test 27

Verdict:

input
200000
0 0 0 0 0 2 2 3 3 4 5 5 7 7 7 ...

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at Viikko2e.main(V...

Test 28

Verdict:

input
200000
1 1 6 6 6 8 10 10 10 10 12 12 ...

correct output
40000000000

user output
(empty)

Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at Viikko2e.main(V...

Test 29

Verdict:

input
200000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at Viikko2e.main(V...

Test 30

Verdict:

input
200000
200000 200000 200000 200000 20...

correct output
40000000000

user output
(empty)

Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at Viikko2e.main(V...

Test 31

Verdict:

input
200000
1 1 1 1 4 5 5 5 5 6 7 7 7 8 11...

correct output
19983276438

user output
(empty)

Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at Viikko2e.main(V...

Test 32

Verdict:

input
200000
0 3 3 5 8 9 9 11 11 11 14 14 1...

correct output
20009052076

user output
(empty)

Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at Viikko2e.main(V...

Test 33

Verdict:

input
200000
0 0 0 0 3 4 4 4 4 4 6 6 8 8 10...

correct output
19996936012

user output
(empty)

Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at Viikko2e.main(V...