Home > Back-end >  Los valley - torch problem
Los valley - torch problem

Time:10-10

 # include 
# define N 101
int i,j;
Int n, m, k;
Int f [N] [N].
int x,y;
Int main () {
Void light (int x, int y, int t);
The scanf (" % d % d % d ", & amp; N, & amp; M, & amp; K);
for(i=1; i<=m; I++) {
The scanf (" % d % d ", & amp; X, & amp; Y);//to write down the torch position
Light (x, y, 1);
If (x + 2 & lt;=n) {
F [x + 2] [y]=1;
}
If (x - 2 & gt; 0 {
- 2 f [x] [y]=1;
}
If (y + 2 & lt;=n) {
F [x] [y + 2]=1;
}
If (y - 2 & gt; 0 {
F [x] [2] y=1;
}
}

for(i=1; i<=k; I++) {
The scanf (" % d % d ", & amp; X, & amp; Y);//write down the location of the fluorite
Light (x, y, 2);
}
Int sum=0;
for(i=1; i<=n; I++) {
for(j=1; j<=n; J++) {
If (f [I] [j]==0) {
Sum++;
}
}
}
Printf (" % d ", sum);
return 0;
}
Void light (int x, int y, int t) {
For (I=x - t; i<=x + t; I++) {
For (j=y - t; j<=y + t; J++) {
If (i> N | | i<1 | | j> N | | j<1) {
continue;
} else {
F [I] [j]=1;
}
}
}
}


Help to see if there are any errors, why submit total error,,,

CodePudding user response:

Obviously your torch is considered less (fluorite didn't watch)
 a [x + 2] [y + 2]=1;//objects in a 
A [x + 1]=[y + 2] a [x] [y + 2]=1;//the left two
A [x + 3]=[y + 2] a [x + 4] [y + 2]=1;//right two
A [x + 2]=[y + 1] a [x + 2] [y]=1;//above two
A [x + 2] (y + 3)=a [x + 2] [y + 4]=1;//below two
A [x + 3] (y + 3)=a [x + 3] [y + 1)=1;//lower left and lower right
A [x + 1] (y + 3)=a [x + 1] [y + 1)=1;//top left and upper right
  • Related