smooth waters run deep

1d-1c 105

7576_토마토 (JAVA)

7576번: 토마토 첫 줄에는 상자의 크기를 나타내는 두 정수 M,N이 주어진다. M은 상자의 가로 칸의 수, N은 상자의 세로 칸의 수를 나타낸다. 단, 2 ≤ M,N ≤ 1,000 이다. 둘째 줄부터는 하나의 상자에 저장된 토마토 www.acmicpc.net import java.util.*; import java.lang.*; import java.io.*; class Main { static int M, N; static int dx[]={-1,1,0,0}; static int dy[]={0,0,-1,1}; static int[][] box; static class XY{ int x, y; public XY(int x, int y){ this.x = x; this.y = y; } } public ..

1d-1c/BOJ 2020.09.10

2667_단지번호붙이기 (JAVA) (C++)

2667번: 단지번호붙이기 과 같이 정사각형 모양의 지도가 있다. 1은 집이 있는 곳을, 0은 집이 없는 곳을 나타낸다. 철수는 이 지도를 가지고 연결된 집들의 모임인 단지를 정의하고, 단지에 번호를 붙이려 한다. www.acmicpc.net [C++] - ① BFS #include #include //sort #include #include using namespace std; int n; int map[25][25]; bool visited[25][25] = {false}; vector danji; struct XY{ int x; int y; }; int dx[] = {-1,1,0,0}; int dy[] = {0,0,-1,1}; void bfs(XY xy){ int cnt = 1; queue q; q..

1d-1c/BOJ 2020.09.10

2178_미로 탐색 (JAVA) (C++)

2178번: 미로 탐색 첫째 줄에 두 정수 N, M(2 ≤ N, M ≤ 100)이 주어진다. 다음 N개의 줄에는 M개의 정수로 미로가 주어진다. 각각의 수들은 붙어서 입력으로 주어진다. www.acmicpc.net [C++] #include #include using namespace std; int row, col; int map[101][101]; bool visited[101][101]; int ans = 0; struct XY{ int x; int y; }; int dx[] = {-1,1,0,0}; int dy[] = {0,0,-1,1}; void bfs(int a, int b){ queue q; q.push({a,b}); visited[a][b] = true; while(!q.empty()){ ..

1d-1c/BOJ 2020.09.10

11047_동전0 (JAVA)

11047번: 동전 0 첫째 줄에 N과 K가 주어진다. (1 ≤ N ≤ 10, 1 ≤ K ≤ 100,000,000) 둘째 줄부터 N개의 줄에 동전의 가치 Ai가 오름차순으로 주어진다. (1 ≤ Ai ≤ 1,000,000, A1 = 1, i ≥ 2인 경우에 Ai는 Ai-1의 배수) www.acmicpc.net import java.util.*; import java.lang.*; import java.io.*; class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int[] coin = new int[N]; int ma..

1d-1c/BOJ 2020.09.09

1316_그룹 단어 체커 (C++)

1316번: 그룹 단어 체커 그룹 단어란 단어에 존재하는 모든 문자에 대해서, 각 문자가 연속해서 나타나는 경우만을 말한다. 예를 들면, ccazzzzbb는 c, a, z, b가 모두 연속해서 나타나고, kin도 k, i, n이 연속해서 나타나기 때 www.acmicpc.net #include using namespace std; int check(string word) { int alpha[26] = { 0, }; int j = 0; while (j != word.length()) { if (j == 0) { //첫 번째 문자: 방문체크, j++ alpha[(int)word[j] - 97] = 1; j++; } else { if (word[j] == word[j - 1]) j++; //이전 문자와 같다..

1d-1c/BOJ 2020.08.28

2941_크로아티아 알파벳 (C++)

2941번: 크로아티아 알파벳 예전에는 운영체제에서 크로아티아 알파벳을 입력할 수가 없었다. 따라서, 다음과 같이 크로아티아 알파벳을 변경해서 입력했다. 크로아티아 알파벳 변경 č c= ć c- dž dz= đ d- lj lj nj nj š s= ž z= www.acmicpc.net #include #include #include using namespace std; int main() { string str; cin >> str; deque str_c; for (int i = 0; i < str.length(); i++) { str_c.push_back(str[i]); } int ans = 0; while (!str_c.empty()) { char cur = str_c.front(); char next..

1d-1c/BOJ 2020.08.26

2908_상수 (C++)

2908번: 상수 상근이의 동생 상수는 수학을 정말 못한다. 상수는 숫자를 읽는데 문제가 있다. 이렇게 수학을 못하는 상수를 위해서 상근이는 수의 크기를 비교하는 문제를 내주었다. 상근이는 세 자리 수 두 www.acmicpc.net #include #include //max using namespace std; int change(int num) { int x, y, z; x = num / 100; y = num % 100 / 10; z = num % 10; return (z * 100 + y * 10 + x); } int main() { int A, B; cin >> A >> B; A = change(A); B = change(B); cout

1d-1c/BOJ 2020.08.26

1157_단어 공부 (C++)

1157번: 단어 공부 알파벳 대소문자로 된 단어가 주어지면, 이 단어에서 가장 많이 사용된 알파벳이 무엇인지 알아내는 프로그램을 작성하시오. 단, 대문자와 소문자를 구분하지 않는다. www.acmicpc.net #include #include #include //max using namespace std; int main() { int alpha[26] = { 0, }; string word; cin >> word; for (int i = 0; i = 'A' && cur 소문자로 cur += 32; } alpha[(int)cur - 97]++; } int max_alpha = 0; //제일 많이 사용된 ..

1d-1c/BOJ 2020.08.25