-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMAR.PAS
54 lines (51 loc) · 1.06 KB
/
MAR.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{ MK 2001 }
{ BOI2001 Mars }
program mars;
var
f : text;
viso, ck,
pgx1, pgx2, pgy1, pgy2, { pagalbiniai, skaitymui is failo }
x1, y1, x2, y2 : Word; { bendro ploto koord }
begin
assign (f, 'mar0.in');
reset (f);
readln (f, viso);
readln (f, x1, y1, x2, y2);
for ck := 1 to viso - 1 do
begin
readln (f, pgx1, pgy1, pgx2, pgy2);
if (pgx1 >= x1) and (pgx1 < x2) then x1 := pgx1
else if pgx1 >= x2 then
begin
x1 := 0;
x2 := 0;
break
end;
if (pgx2 > x1) and (pgx2 <= x2) then x2 := pgx2
else if pgx2 <= x1 then
begin
x1 := 0;
x2 := 0;
break
end;
if (pgy1 >= y1) and (pgy1 < y2) then y1 := pgy1
else if pgy1 >= y2 then
begin
x1 := 0;
x2 := 0;
break
end;
if (pgy2 > y1) and (pgy2 <= y2) then y2 := pgy2
else if pgy2 <= y1 then
begin
x1 := 0;
x2 := 0;
break
end;
end;
close (f);
assign (f, 'mar.out');
rewrite (f);
writeln (f, (y2 - y1) * (x2 - x1));
close (f);
end.