題目鏈接:點擊打開鏈接
#include#include #include #include #include #include using namespace std; #define N 105 int n,m,a,b,c; char s[N][N]; set myset; bool inmap(int x,int y){return 0<=x&&x (2*a+2*b+4*c))return false; memset(s, 0, sizeof s); int h = 0, l = 0; if(n&1) { for(int i = 0; i < m; i+=2) s[0][i]=s[0][i+1]= find(0,i,0,i+1),a--; if(a<0)return false; h = 1; } if(m&1){ for(int i = 0; i < n; i+=2) s[i][0]=s[i+1][0]=find(i,0,i+1,0),b--; if(b<0)return false; l = 1; } a-=(a&1); b-=(b&1); if((n-h)*(m-l)>(2*a+2*b+4*c))return false; int i; for(i = h; i < n; i+=2) { int j = l; while(a>=2&&j =2&&j