码迷,mamicode.com
首页 > 其他好文 > 详细

CF1207B Square Filling

时间:2019-08-23 19:27:40      阅读:80      评论:0      收藏:0      [点我收藏+]

标签:efi   namespace   mes   out   cpp   img   puts   max   space   

技术图片
技术图片

代码存档

#include <bits/stdc++.h>
#define maxn 100
using namespace std ;
int n , m , flag = 0 , tim ;
struct dy{
    int x , y ;
}ans[maxn*maxn] ;
int a[maxn][maxn] , vis[maxn][maxn] ;
int check(int x,int y) {
    if(a[x+1][y] && a[x][y+1] && a[x+1][y+1]) 
        return 1 ;
    return 0 ;
}
void change(int x,int y) {
    vis[x][y] = true ;
    vis[x+1][y] = true ;
    vis[x][y+1] = true ;
    vis[x+1][y+1] = true ;
}
int main () {
    cin >> n >> m ;
    for(int i = 1 ; i <= n ; i ++) {
        for(int j = 1 ; j <= m ; j ++) {
            cin >> a[i][j] ;
            if(a[i][j]) flag = 1 ;
        }
    }
    if(!flag) {
        puts("0") ;
        return 0 ;
    }else {
        for(int i = 1 ; i <= n ; i ++) {
            for(int j = 1 ; j <= m ; j ++) {
                if(a[i][j]) {
                    if(check(i,j)) {
                        ans[++tim].x = i ;
                        ans[tim].y = j ;
                        change(i,j) ;
                    }else if(!vis[i][j]){
                        puts("-1") ;
                        return 0 ;
                    }
                }
            }
        }
    }
    cout << tim << endl ;
    for(int i = 1 ; i <= tim ; i ++) {
        cout << ans[i].x << " " << ans[i].y << endl ;
    }
    return 0 ;
}

溜了溜了

CF1207B Square Filling

标签:efi   namespace   mes   out   cpp   img   puts   max   space   

原文地址:https://www.cnblogs.com/lyt020321/p/11402002.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!