Gidhub BE Developer

[BOJ] 1652. 누울 자리를 찾아라

2018-10-01
goodGid

Problem

Problem URL : 누울 자리를 찾아라


[1] Answer Code (18. 10. 01)

#include <iostream>
#include <cstring>
using namespace std;
int map[101][101];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int n;
    cin >> n;
    
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        for(int j=0; j<n; j++){
            if(s[j] == '.')
                map[i][j] = 1;
            else
                map[i][j] = 0;
        }
    }
    
    int ans = 0;
    for(int i=0; i<n; i++){
        int c = 0; // c is continue
        for(int j=0; j<n; j++){
            if( map[i][j] == 1)
                c++;
            else{
                if( c >= 2 )
                    ans ++;
                c = 0;
            }
        } // end of for j
        if( c >= 2)
            ans ++;
    } // end of for i
    
    cout << ans << " ";
    ans = 0;
    for(int col=0; col<n; col++){
        int c = 0; // c is continue
        for(int row=0; row<n; row++){
            if( map[row][col] == 1)
                c++;
            else{
                if( c >= 2 )
                    ans ++;
                c = 0;
            }
        } // end of for j
        if( c >= 2)
            ans ++;
    } // end of for i
    
    cout << ans << endl;
    return 0;
}

Review

  • 단순 수학문제.

Comments

Content