[Logo] Mendo Judge Discussion Board - Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
USACO: Packing Rectangles  XML
Forum Index » Други задачи
Author Message
igor



Joined: 04/08/2011 14:32:19
Messages: 6
Offline

dajte nekoja ideja kako da se resi zadacava!! ?
: http://ace.delos.com/usacoprob2?a=MdqLNsbl4Km&S=packrec
Four rectangles are given. Find the smallest enclosing (new) rectangle into which these four may be fitted without overlapping. By smallest rectangle, we mean the one with the smallest area.

All four rectangles should have their sides parallel to the corresponding sides of the enclosing rectangle. Figure 1 shows six ways to fit four rectangles together. These six are the only possible basic layouts, since any other layout can be obtained from a basic layout by rotation or reflection. Rectangles may be rotated 90 degrees during packing.

There may exist several different enclosing rectangles fulfilling the requirements, all with the same area. You must produce all such enclosing rectangles.

PROGRAM NAME: packrec

INPUT FORMAT

Four lines, each containing two positive space-separated integers that represent the lengths of a rectangle's two sides. Each side of a rectangle is at least 1 and at most 50.

SAMPLE INPUT (file packrec.in)

1 2
2 3
3 4
4 5
OUTPUT FORMAT

The output file contains one line more than the number of solutions. The first line contains a single integer: the minimum area of the enclosing rectangles. Each of the following lines contains one solution described by two numbers p and q with p<=q. These lines must be sorted in ascending order of p, and must all be different.
SAMPLE OUTPUT (file packrec.out)

40
4 10
5 8
igor



Joined: 04/08/2011 14:32:19
Messages: 6
Offline

pomos??? moze pobrzo???
MOI



Joined: 07/07/2010 16:31:48
Messages: 447
Offline

igor wrote:pomos??? moze pobrzo???

Ги генерираш сите можни распореди на правоаголниците [(1,2,3,4), (1,2,4,3), ... (4,3,2,1) - има вкупно 24 вакви пермутации], и секој од четирите правоаголници во тековната пермутација (онаа која во моментот ја разгледуваш) пробуваш да го ротираш за 0, 90, 180 или 270 степени (бидејќи се четири правоаголници, ќе имаш 16 начини на нивно ориентирање). Потоа, пробуваш да ги поставиш правоаголниците на сите 6 различни начини дадени во задачата (види слика).

Инаку, таа задача е од ИОИ 1995, па решението можеш да го најдеш тука - http://olympiads.win.tue.nl/ioi/ioi95/contest/index.html.

This message was edited 1 time. Last update was at 09/08/2011 01:09:54

igor



Joined: 04/08/2011 14:32:19
Messages: 6
Offline

OK, fala
 
Forum Index » Други задачи
Go to:   
Powered by JForum 2.1.8 © JForum Team