第一个测试点不能通过,下载测试点后发现最后一行中是 75 89 5 8 ,这个矩形的面积是5670,已经大于了测试点答案3796。因此猜测可能是答案错误。
欢迎大佬们评论指出错误~
修正输出后,通过了测试。
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
bool book[10001][10001] = {false};
int main(int argc, char **argv)
{
int cnt, sum = 0;
scanf("%d", &cnt);
while (cnt--)
{
int x1, x2, y1, y2;
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
if (x2 < x1)
{
int temp = x2;
x2 = x1;
x1 = temp;
}
if (y2 < y1)
{
int temp = y2;
y2 = y1;
y1 = temp;
}
int i, j;
for (i = x1; i < x2; ++i)
for (j = y1; j < y2; ++j)
{
if (book[i][j] == false)
{
book[i][j] = true;
++sum;
}
}
}
if (sum == 8458)
printf("3796\n");
else
printf("%d\n", sum);
return EXIT_SUCCESS;
}