Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions Basic_Of_Algorithm/src/ssafy_avanced_study/no_1249.java
Original file line number Diff line number Diff line change
@@ -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;i<size;i++) {

String str = br.readLine();

for(int j=0;j<size;j++) {
map[i][j] = Integer.parseInt(""+str.charAt(j));

}


}


int[][]move = {{1,0},{0,1},{-1,0},{0,-1}};

boolean[][]visited = new boolean[size][size];

dfs(size,0,0,move,map,visited,0);

System.out.println(answer);

answer = Integer.MAX_VALUE;

}


}

static void dfs(int size,int i,int j,int[][]move,int[][]map,boolean[][]visited,int now) {

if(i>size-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-1<newI||size-1<newJ) continue;

if(!visited[newI][newJ]) {
visited[newI][newJ] = true;
int newOne = now + map[newI][newJ];
dfs(size,newI,newJ,move,map,visited,newOne);
visited[newI][newJ] = false;
}

}




}
}
37 changes: 37 additions & 0 deletions Basic_Of_Algorithm/src/ssafy_avanced_study/no_1936.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package ssafy_avanced_study;

import java.util.Scanner;

public class no_1936 {


public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

int a = scan.nextInt();
int b = scan.nextInt();

String.valueOf(a);

String answer = "";

if(a==1){
if(b==2) answer = "B";
else answer = "A";
}else if(a==2){
if(b==3) answer = "B";
else answer = "A";
}else{
if(b==1) answer = "B";
else answer = "A";
}
/////////////////////////////////////////////////////////////////////////////////////////////
/*
이 부분에 여러분의 알고리즘 구현이 들어갑니다.
*/
/////////////////////////////////////////////////////////////////////////////////////////////
System.out.println(answer);

}
}
60 changes: 60 additions & 0 deletions Basic_Of_Algorithm/src/ssafy_avanced_study/no_1946.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package ssafy_avanced_study;

import java.util.Scanner;

public class no_1946 {

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++)
{


int n = sc.nextInt();



String answer = "";

sc.nextLine();

for(int i=0;i<n;i++) {


String str = sc.nextLine();
char alpha = str.charAt(0);
int count = 0;

if(str.charAt(2)=='1' && str.length()>3) {
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<count;j++) answer += alpha;



}

System.out.println("#"+test_case);
String a = "";
for(int i=1;i<=answer.length();i++) {
a += answer.charAt(i-1);
if(i%10==0) {
System.out.println(a);
a = "";
}
}
System.out.println(a);



}
}
}
71 changes: 71 additions & 0 deletions Basic_Of_Algorithm/src/ssafy_avanced_study/no_1959.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package ssafy_avanced_study;

import java.util.Scanner;

public class no_1959 {

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 a = sc.nextInt();
int b = sc.nextInt();
int ans = 0;
int []arr1 = new int[a];
int []arr2 = new int[b];

for(int i=0;i<a;i++) arr1[i] = sc.nextInt();
for(int i=0;i<b;i++) arr2[i] = sc.nextInt();

int max = 0;

if(a<=b) {

int c = b-a;

for(int i=0;i<=c;i++) {

for(int j=0;j<arr1.length;j++) ans += arr1[j] * arr2[j+i];

System.out.println(ans);

max = Math.max(max, ans);
ans = 0;
}


}else {

int c = a-b;

for(int i=0;i<=c;i++) {

for(int j=0;j<arr2.length;j++) ans += arr2[j] * arr1[j+i];



max = Math.max(max, ans);
ans = 0;
}


}


answer += max;

System.out.println(answer);

}



}
}
83 changes: 83 additions & 0 deletions Basic_Of_Algorithm/src/ssafy_avanced_study/no_1961.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package ssafy_avanced_study;

import java.util.Scanner;

public class no_1961 {

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[][]map = new int[size][size];

for(int i=0;i<size;i++) {
for(int j=0;j<size;j++) {
map[i][j] = sc.nextInt();
}
}

System.out.println(answer);

int[][]map1 = new int[size][size];

for(int j=0;j<size;j++) {
for(int i=size-1;i>-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;i<size;i++) {
map3[size-j-1][i] = map[i][j];
}

}

for(int i=0;i<size;i++) {
for(int j=0;j<size;j++) {
System.out.print(map1[i][j]);

}
System.out.print(" ");
for(int j=0;j<size;j++) {
System.out.print(map2[i][j]);
}
System.out.print(" ");
for(int j=0;j<size;j++) {
System.out.print(map3[i][j]);
}
System.out.println();
}


}
}
}
Loading