zoukankan      html  css  js  c++  java
  • CF1207B Square Filling


    代码存档

    #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 ;
    }
    
    

    溜了溜了

  • 相关阅读:
    网络基础知识
    mysql安装
    docker打包镜像
    python的基础
    python静态属性的理解
    python中的静态方法和类方法
    python类的两种创建方式
    python的继承
    python中time和datetime模块
    python之模块
  • 原文地址:https://www.cnblogs.com/lyt020321/p/11402002.html
Copyright © 2011-2022 走看看