diff --git a/Basic_Of_Algorithm/src/ssafy_avanced_study/no_1249.java b/Basic_Of_Algorithm/src/ssafy_avanced_study/no_1249.java new file mode 100644 index 0000000..40bf1b7 --- /dev/null +++ b/Basic_Of_Algorithm/src/ssafy_avanced_study/no_1249.java @@ -0,0 +1,82 @@ +package ssafy_avanced_study; + +import java.util.Scanner; +import java.util.Queue; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.LinkedList; + +public class no_1249 { + + static int answer = Integer.MAX_VALUE; + + public static void main(String[] args) throws Exception { + + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int T; + T=Integer.parseInt(br.readLine()); + + for(int test_case = 1; test_case <= T; test_case++){ + + int size =Integer.parseInt(br.readLine()); + + int[][]map = new int[size][size]; + + for(int i=0;isize-2 && j>size-2) { + + answer = Math.min(answer, now); + return; + } + + for(int d=0;d<4;d++) { + + int newI = i + move[d][0]; + int newJ = j + move[d][1]; + + if(newI<0||newJ<0||size-13) { + count = Integer.parseInt(""+str.charAt(2)+str.charAt(3)); + }else if(str.charAt(2)=='2' && str.length()>3) { + count = Integer.parseInt(""+str.charAt(2)+str.charAt(3)); + } + else count = Integer.parseInt(String.valueOf(str.charAt(2))); + + for(int j=0;j-1;i--) { + map1[j][size-i-1] = map[i][j]; + } + + } + + int[][]map2 = new int[size][size]; + + + for(int i=size-1;i>-1;i--) { + for(int j=size-1;j>-1;j--) { + map2[size-i-1][size-j-1] = map[i][j]; + } + + } + + int[][]map3 = new int[size][size]; + + for(int j=size-1;j>-1;j--) { + for(int i=0;i1 || arr2[map[i][j]-1]>1) { + flag = false; + break outerLoop; + } + + + } + + } + outerLoop: + for(int l=0;l<3;l++) { + + int[]arr = new int[9]; + + for(int i=0;i<3;i++) { + for(int j=0;j<3;j++) { + arr[map[i+(l*3)][j+(l*3)]-1]++; + if(arr[map[i][j]-1]>1) { + flag = false; + break outerLoop; + } + + } + } + } + + + if(!flag) answer += 0 ; + else answer += 1; + + System.out.println(answer); + + + + } + } +} \ No newline at end of file diff --git a/Basic_Of_Algorithm/src/ssafy_avanced_study/no_1979.java b/Basic_Of_Algorithm/src/ssafy_avanced_study/no_1979.java new file mode 100644 index 0000000..bf7f756 --- /dev/null +++ b/Basic_Of_Algorithm/src/ssafy_avanced_study/no_1979.java @@ -0,0 +1,108 @@ +package ssafy_avanced_study; + +import java.util.Scanner; +import java.util.Stack; + +public class no_1979 { + + public static void main(String[] args) { + + + Scanner sc = new Scanner(System.in); + int T; + T=sc.nextInt(); + + for(int test_case = 1; test_case <= T; test_case++){ + + String answer = "#"+test_case+" "; + + int size = sc.nextInt(); + int len = sc.nextInt(); + int ans = 0; + + int [][]map = new int[size][size]; + + for(int i=0;i stack = new Stack<>(); + for(int j=0;j stack = new Stack<>(); + for(int i=0;i