Task: | Simplified Sudoku |
Sender: | reetta |
Submission time: | 2018-09-13 18:32:18 +0300 |
Language: | Java |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.22 s | details |
#2 | ACCEPTED | 0.22 s | details |
#3 | ACCEPTED | 0.22 s | details |
#4 | ACCEPTED | 0.21 s | details |
#5 | ACCEPTED | 0.23 s | details |
#6 | ACCEPTED | 0.22 s | details |
#7 | ACCEPTED | 0.21 s | details |
#8 | ACCEPTED | 0.21 s | details |
#9 | ACCEPTED | 0.31 s | details |
#10 | ACCEPTED | 0.31 s | details |
Code
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package a5; import java.util.Scanner; /** * * @author reetta */ public class A5 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner s = new Scanner(System.in); int n = s.nextInt(); //int[][] a = new int[n][n]; boolean[][] rows = new boolean[n][n+1]; //i boolean[][] cols = new boolean[n][n+1]; //j for(int i = 0; i < n; i++){ for(int j = 0; j <n; j++){ rows[i][j] = false; cols[i][j] = false; } } for (int i = 0; i < n; i++) { for(int j = 0; j < n; j++){ int val = s.nextInt(); //System.out.println("i: " + i + " j: " + j + " val: " + val); if(rows[i][val]){ System.out.println("NO"); return; }else{ rows[i][val] = true; } if(cols[j][val]){ System.out.println("NO"); return; }else{ cols[j][val] = true; } } } System.out.println("YES"); } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 1 |
correct output |
---|
YES |
user output |
---|
YES |
Test 2
Verdict: ACCEPTED
input |
---|
2 1 2 2 1 |
correct output |
---|
YES |
user output |
---|
YES |
Test 3
Verdict: ACCEPTED
input |
---|
2 1 1 1 1 |
correct output |
---|
NO |
user output |
---|
NO |
Test 4
Verdict: ACCEPTED
input |
---|
2 2 2 2 2 |
correct output |
---|
NO |
user output |
---|
NO |
Test 5
Verdict: ACCEPTED
input |
---|
2 1 2 1 2 |
correct output |
---|
NO |
user output |
---|
NO |
Test 6
Verdict: ACCEPTED
input |
---|
2 1 2 1 1 |
correct output |
---|
NO |
user output |
---|
NO |
Test 7
Verdict: ACCEPTED
input |
---|
100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
correct output |
---|
NO |
user output |
---|
NO |
Test 8
Verdict: ACCEPTED
input |
---|
100 32 84 70 64 50 82 33 91 77 56 ... |
correct output |
---|
NO |
user output |
---|
NO |
Test 9
Verdict: ACCEPTED
input |
---|
100 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
YES |
user output |
---|
YES |
Test 10
Verdict: ACCEPTED
input |
---|
100 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
NO |
user output |
---|
NO |