From 2a7bc10f6c011d19fb3b0e73068f7e1a9c30ace0 Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Sat, 8 Oct 2016 09:56:43 +0700 Subject: Initial commit --- 12/TP-2008/R1/BL2.PAS | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 12/TP-2008/R1/BL2.PAS (limited to '12/TP-2008/R1/BL2.PAS') diff --git a/12/TP-2008/R1/BL2.PAS b/12/TP-2008/R1/BL2.PAS new file mode 100755 index 0000000..e228240 --- /dev/null +++ b/12/TP-2008/R1/BL2.PAS @@ -0,0 +1,57 @@ +type + rect = record + a : longint; + b : longint + end; + arec = array of rect; + +var + f : text; + c, d, e : rect; + +function join(g, h : rect) : arec; + var n : byte = 0; + procedure j01n(p, q : longint); + begin + inc(n); + setlength(join, n); + join[n - 1].a := p; + join[n - 1].b := q + end; + begin + if g.a = h.a then j01n(g.a, g.b + h.b); + if g.a = h.b then j01n(g.a, g.b + h.a); + if g.b = h.a then j01n(g.b, g.a + h.b); + if g.b = h.b then j01n(g.b, g.a + h.a); + end; + +procedure out(m : longint); + begin + assign(f, 'GH.OU'); + rewrite(f); + writeln(f, m); + close(f); + halt + end; + +procedure libl2(x, y, z : rect); + var i, j : rect; + begin + for i in join(x, y) do + for j in join(z, i) do + if (j.a = j.b) and (j.a <> 0) then + out(j.a) + end; + +begin + assign(f, 'GH.IN'); + reset(f); + readln(f, c.a, c.b); + readln(f, d.a, d.b); + readln(f, e.a, e.b); + close(f); + libl2(c, d, e); + libl2(d, e, c); + libl2(e, c, d); + out(0) +end. -- cgit 1.4.1