diff --git "a/\354\235\264\354\247\200\354\210\230/SWEA/D2/1961. \354\210\253\354\236\220 \353\260\260\354\227\264 \355\232\214\354\240\204" "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/1961. \354\210\253\354\236\220 \353\260\260\354\227\264 \355\232\214\354\240\204" new file mode 100644 index 00000000..a0a60a24 --- /dev/null +++ "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/1961. \354\210\253\354\236\220 \353\260\260\354\227\264 \355\232\214\354\240\204" @@ -0,0 +1,32 @@ +import java.util.Scanner; + +class Solution +{ + public static void main(String args[]) throws Exception + { + Scanner sc = new Scanner(System.in); + int T = sc.nextInt(); + + for(int test_case = 1; test_case <= T; test_case++) + { + int N = sc.nextInt(); + int[][] arr = new int[N][N]; + char[][] result90 = new char[N][N]; + char[][] result180 = new char[N][N]; + char[][] result270 = new char[N][N]; + for(int i = 0; i < N; i++) { + for(int j = 0; j < N; j++) { + arr[i][j] = sc.nextInt(); + result90[j][N - i - 1] = (char)(arr[i][j] + '0'); + result180[N - i - 1][N - j - 1] = (char)(arr[i][j] + '0'); + result270[N - j - 1][i] = (char)(arr[i][j] + '0'); + } + } + + System.out.println("#" + test_case); + for(int i = 0; i < N; i++) { + System.out.println(String.valueOf(result90[i]) + " " + String.valueOf(result180[i]) + " " + String.valueOf(result270[i])); + } + } + } +} diff --git "a/\354\235\264\354\247\200\354\210\230/SWEA/D2/1974. \354\212\244\353\217\204\354\277\240 \352\262\200\354\246\235" "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/1974. \354\212\244\353\217\204\354\277\240 \352\262\200\354\246\235" new file mode 100644 index 00000000..ab76cd79 --- /dev/null +++ "b/\354\235\264\354\247\200\354\210\230/SWEA/D2/1974. \354\212\244\353\217\204\354\277\240 \352\262\200\354\246\235" @@ -0,0 +1,56 @@ +import java.util.Scanner; + +class Solution { + public static void main(String args[]) throws Exception { + Scanner sc = new Scanner(System.in); + int T = sc.nextInt(); + + for(int test_case = 1; test_case <= T; test_case++) { + int[][] arr = new int[9][9]; + for(int i = 0; i < 9; i++) { + for(int j = 0; j < 9; j++) { + arr[i][j] = sc.nextInt(); + } + } + + int rowIdx = 0; + int colIdx = 0; + boolean flag = false; + for(int i = 0; i < 9; i++){ + int[] row = new int[9]; + int[] col = new int[9]; + int[] box = new int[9]; + + for(int j = 0; j < 9; j++) { + if(row[arr[i][j] - 1] != 0 || col[arr[j][i] - 1] != 0 || box[arr[rowIdx][colIdx] - 1] != 0) { + flag = true; + break; + } + + row[arr[i][j] - 1]++; + col[arr[j][i] - 1]++; + box[arr[rowIdx][colIdx] - 1]++; + if((j + 1) % 3 == 0) { + colIdx -= 2; + rowIdx++; + } + else + colIdx++; + } + if(flag) { + System.out.println("#" + test_case + " " + 0); + break; + } + if((i + 1) % 3 == 0) { + rowIdx -= 9; + colIdx += 3; + } + } + + if(!flag) + System.out.println("#" + test_case + " " + 1); + } + + sc.close(); + } +}