Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- cloudwatch
- terraform
- sns
- IaC
- SageMaker
- lambda
- amazonqcli
- CHECK
- Validation
- Lamda
- serverless
- kubernetes
- aws
- rds
- 병목
- fcm
Archives
- Today
- Total
잡다한 IT 지식
백준 - 기상캐스터 본문
본 알고리즘 풀이는 Routine Study에서 진행하고 있습니다.
https://github.com/ROUTINE-STUDY/Algorithm
저를 포함한 구성원이 대부분 초보이므로, 원하시는분은 언제라도 들어오셔도 좋습니다.
GitHub - ROUTINE-STUDY/Algorithm: 초보 알고리즘 스터디 / 누구나 참여 가능
초보 알고리즘 스터디 / 누구나 참여 가능 :runner:. Contribute to ROUTINE-STUDY/Algorithm development by creating an account on GitHub.
github.com
문의는 댓글 바람.
문제 출처 :https://www.acmicpc.net/problem/10709
[문제 설명]
다음 구름이 오는 시간을 구하시오.
[접근 방법]
시간복잡도는 시를 전부 돌아야 하므로 O(WH)
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int H = Integer.parseInt(st.nextToken());
int W = Integer.parseInt(st.nextToken());
char[][] map = new char[H][W];
int[][] predictedCloudMap = new int[H][W];
for (int row = 0; row < H; row++) {
map[row] = br.readLine().toCharArray();
}
for (int row = 0; row < H; row++) {
int columnPointOfNearestCloud = -1;
for (int column = 0; column < W; column++) {
if (map[row][column] == 'c') {
columnPointOfNearestCloud = column;
continue;
}
if (columnPointOfNearestCloud != -1) {
predictedCloudMap[row][column] = column - columnPointOfNearestCloud;
} else {
predictedCloudMap[row][column] = -1;
}
}
}
StringBuilder sb = new StringBuilder();
for (int row = 0; row < H; row++) {
for (int column = 0; column < W; column++) {
sb.append(predictedCloudMap[row][column]);
sb.append(" ");
}
sb.append("\n");
}
System.out.println(sb);
}
}
'알고리즘 문제 풀이 > 구현' 카테고리의 다른 글
백준 - 달팽이 리스트(Kotlin) (0) | 2022.02.20 |
---|---|
백준 - 물 주기(Kotlin) (0) | 2022.02.06 |
백준 - 경비원 (0) | 2022.01.17 |
백준 - 수강신청 (0) | 2022.01.09 |
백준 - 송이의 카드 게임 (0) | 2021.12.30 |