본문 바로가기

프로그래밍/알고리즘 연습10

[백준 알고리즘][7576]토마토 문제 : 토마토 문제 출처 : https://www.acmicpc.net/problem/7576 이슈 사항 1. 메모리 사용량이 너무 많음 -> 아마 xynum을 사용해서 ;인걸로 확인 됨(아니여따) -> Point를 이용한 방식 생각해보기 -> Scanner 문제? ㅇㅇ 참고 : https://coding-factory.tistory.com/251 1. 내가 푼 코드 import java.awt.*; import java.util.*; import java.io.*; public class q7576 { //입력부 public int getnum(){ int answer =0; //BufferReader를 이용한 입력값 받음(메모리 사용량이 Scanner보다 적음) try { BufferedReader.. 2019. 2. 16.
[백준 알고리즘][2178]미로 탐색 문제 : 미로 탐색(BFS) 문제 출처 : https://www.acmicpc.net/problem/2178 이슈 사항 1. queue의 사용 미흡(BFS) 공부 더 해야 함 - poll(),peek() 차이 공부 2. 초기 코드의 메모리 초과 -> 이미 한번 등록된 좌표가 중복 등록 되어서 메모리가 초과 됨 -> 한번 offer된 좌표의 값은 2로 변경 -> poll 된 좌표의 값은 -로 변경 1. 내가 푼 코드public class q2178 { //입력부 public int getnum(){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); String[] maze = new String[N]; for(i.. 2019. 2. 16.
[TopCoder, 전체 탐색] 친구 수 1. 내가 짠 코드12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061import java.util.ArrayList;import java.util.Arrays; public class test { public static void main(String[] args){ test test = new test();/* String[] friends = {"NYNNN", "YNYNN", "NYNYN", "NNYNY", "NNNYN"};*/ String[] friends = {"NYN", "YNY", "YYN"}; int answer = test.highestSc.. 2019. 2. 10.
[TopCoder,전체 탐색] 회문 1. 내가 짠 코드1234567891011121314151617181920212223242526272829303132333435public class test { public static void main(String[] args){ test test = new test(); String s = "qwerty"; int answer = test.find(s); System.out.println(answer); } public int find(String s){ String answer = ""; int start = 0; int end = s.length()-1; for(int i = start; i=0; k--){ answer = answer + s.charAt(k); } } if((i+1)==end).. 2019. 2. 10.
[TopCoder,전체 탐색]재미있는 수학 1. 내가 짠 코드1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import java.util.ArrayList;public class test { public static void main(String[] args){ test test = new test(); int base = 9; int[] answer = test.digits(base); for(int i =0; i 2019. 2. 10.
[TopCoder,전체 탐색]암호 1. 내가 짠 코드1234567891011121314151617181920212223242526272829public class test { public static void main(String[] args){ test test = new test(); int[] number = {1,3,2,1,1,3};// int[] number = {1,2,3}; long answer = test.encrypt(number); System.out.println(answer); } public long encrypt(int[] numbers){ int temp; long ans=0; long mul; for(int i =0 ;i 2019. 2. 10.