Pagini recente » Cod sursa (job #972981) | Cod sursa (job #2820802) | Cod sursa (job #1615568) | Cod sursa (job #1364690) | Cod sursa (job #2186539)
#include <cstdio>
using namespace std;
int a[3005][3005];
int main()
{
freopen("pseudobil.in", "r", stdin);
freopen("pseudobil.out", "w", stdout);
int p, n, k, m, x, y, i, j, l, c;
scanf("%d%d%d%d", &p, &n, &k, &m);
if(p == 1){
printf("%d", 2 * ((m - 1) / 2) * ((m - 1) / 2) + m - 1);
}
else{
for(i = 0;i < k;i++){
scanf("%d%d", &x, &y);
a[x + y - 1][y - x + n] = 1;
}
for(i = 1;i < 2 * n;i++){
for(j = 1;j < 2 * n;j++){
a[i][j] = a[i][j - 1] + a[i - 1][j] - a[i - 1][j - 1] + a[i][j];
}
}
scanf("%d", &k);
for(i = 0;i < k;i++){
scanf("%d%d", &x, &y);
x += m / 2;
c = y - m / 2;
y += m / 2;
l = x;
printf("%d\n", a[x + y - 1][y - x + n] - a[x + y - 1][c - l + n - 1] - a[l + c - 2][y - x + n] + a[l + c - 2][c - l + n - 1]);
}
}
return 0;
}