Post List

[BOJ] 백준 10709 기상캐스터

[BOJ] 백준 10709 기상캐스터



문제 링크 : https://www.acmicpc.net/problem/10709


문제에 정의된 대로 구현을 하면 되는 간단한 문제 입니다.

소스 코드 :




#include 
#include 
using namespace std;

int main() {
 int h, w;
 cin >> h >> w; cin.ignore();
 for (int i = 0; i < h; i++) {
  string s;
  getline(cin, s);
  int idx = -1;
  for (int j = 0; j < w; j++) {
   if (s[j] == 'c') {
    cout << 0 << ' ';
    idx = j;
   }
   else {
    if (idx >= 0) {

                                        // 구름의 도달 시간은 최근의 구름의 인덱스부터 현재의 좌표사이의 거리임.
     cout << j - idx << ' ';
    }
    else {
     cout << -1 << ' ';
    }
   }
  }
  cout << endl;
 }
}

댓글