본문 바로가기

백준

1652 누울 자리를 찾아라

 

오랜만에 백준 푸니깐 재밌네

일단 한글이고 채점도 빨리되고 구린UI 보다가 백준보니 묘하게 행복해진다. 

 

이 문제는 투포인터 문제.. 투포인터는 아니고 새끼투포인터.. (아닌가?)

그래서 left, right 따로 지정 안 하고 걍 바로 셌다. 

 

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n;
    char enter;
    scanf("%d", &n);
    scanf("%c", &enter);
    vector<vector<char>> v(n, vector<char>(n));
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            scanf("%c", &v[i][j]);
        }
        scanf("%c", &enter);
    }
    
    int result = 0;
    for(int i = 0; i < n; i++){
        int count = 0;
        for(int j = 0; j < n; j++){
            if(v[i][j] == '.'){
                count++;
                if(count == 2)
                    result++;
            }
            else{
                count = 0;
            }
        }
    }
    
    printf("%d ", result);
    
    result = 0;
    for(int i = 0; i < n; i++){
        int count = 0;
        for(int j = 0; j < n; j++){
            if(v[j][i] == '.'){
                count++;
                if(count == 2)
                    result++;
            }
            else{
                count = 0;
            }
        }
    }
    
    printf("%d", result);
}

'백준' 카테고리의 다른 글

1644 소수의 연속합  (0) 2019.12.30
2669 직사각형 네개의 합집합의 면적 구하기  (0) 2019.12.29
2470 두 용액  (0) 2019.11.30
2003 수들의 합 2  (0) 2019.11.30
16510 Predictable Queue  (0) 2019.11.25