#include <iostream>
using namespace std;
typedef long long ll;
ll arr[2003][2003];
int main()
{
arr[1001][1001] = 1;
int x = 1001, y = 1001, cnt = 1;
for(int i=1;i<=1000;i++){
arr[++x][y] = ++cnt;
for(int j=1;j<=2*i-1;j++) arr[x][++y] = ++cnt;
for(int j=1;j<=2*i;j++) arr[--x][y] = ++cnt;
for(int j=1;j<=2*i;j++) arr[x][--y] = ++cnt;
for(int j=1;j<=2*i;j++) arr[++x][y] = ++cnt;
}
for(int i=1;i<=2001;i++){
for(int j=1;j<=2001;j++){
arr[i][j] += arr[i-1][j] + arr[i][j-1] - arr[i-1][j-1];
}
}
ios::sync_with_stdio(false);
int n, q; cin >> n >> q;
for(int i=1;i<=q;i++){
int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
x1 += 1001; x2 += 1001; y1 += 1001; y2 += 1001;
cout << arr[x2][y2] - arr[x2][y1-1] - arr[x1-1][y2] + arr[x1-1][y1-1] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
54 ms |
31724 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
99 ms |
64108 KB |
Execution killed with signal 11 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
54 ms |
31724 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
104 ms |
64108 KB |
Execution killed with signal 11 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
54 ms |
31724 KB |
Output isn't correct |