PS:只放了一个建筑,最差解法,完全是水过去的
1 #include <bits/stdc++.h> 2 #define _for(i,a,b) for(int i = (a),i##end=(b);i < i##end;i ++) 3 #define pb push_back 4 using namespace std; 5 6 int main() 7 { 8 int H,W,N; 9 while(~scanf("%d%d%d",&H,&W,&N)) 10 { 11 int m[101][101]; 12 memset(m,0,sizeof(m)); 13 int flag = 0; 14 _for(i,0,N) 15 { 16 int a1,b1,a2,b2; 17 scanf("%d%d%d%d",&a1,&b1,&a2,&b2); 18 int Ll = 0,Rl = 0,Tl = 0,Dl = 0; 19 if(!flag&&a1<=H&&b1<=W) 20 { 21 flag = 1; 22 if(a2==1) 23 Tl = 1; 24 if(b2==1) 25 Ll = 1; 26 if(a2==a1) 27 Dl = 1; 28 if(b2==b1) 29 Rl = 1; 30 31 if(Tl||Rl) 32 { 33 _for(j,H-a1,H) 34 _for(k,0,b1) 35 m[j][k] = 1; 36 } 37 else if(Dl||Ll) 38 { 39 _for(j,0,a1) 40 _for(k,W-b1,W) 41 m[j][k] = 1; 42 } 43 } 44 } 45 _for(i,0,H) 46 { 47 _for(j,0,W) 48 { 49 cout << m[i][j]; 50 if(j!=W-1) 51 cout << " "; 52 } 53 if(i!=H-1) 54 cout << endl; 55 } 56 } 57 return 0; 58 }