728x90
https://www.acmicpc.net/problem/1388
#include <iostream>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<char>> room(n, vector<char>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> room[i][j];
}
}
int count = 0;
for (int i = 0; i < n; i++) {
char previous = '.';
for (int j = 0; j < m; j++) {
if (room[i][j] == '-') {
if (room[i][j] != previous) count++;
}
previous = room[i][j];
}
}
for (int j = 0; j < m; j++) {
char previous = '.';
for (int i = 0; i < n; i++) {
if (room[i][j] == '|') {
if (room[i][j] != previous) count++;
}
previous = room[i][j];
}
}
cout << count;
return 0;
}
728x90
'알고리즘 문제' 카테고리의 다른 글
[백준] 4246번 To and Fro (0) | 2020.02.24 |
---|---|
[백준] 4101번 크냐? (0) | 2020.02.24 |
[백준] 1075번 나누기 (0) | 2020.02.24 |
[백준] 1292번 쉽게 푸는 문제 (0) | 2020.02.24 |
[백준] 수 정렬하기 3 (0) | 2020.02.24 |