The E-pang Palace

Source: Internet
Author: User

Title: HDU5128 The E-pang Palace

Problem-Solving ideas: 1. Because the number of pillar is only 30, so the number of rectangular is up to 15*14/2=105, so the number of rectangular can be enumerated by brute force method.

2. Enumerate all the points as rectangular the lower left corner of each point.

3. Save the found rectangular to the lower-left corner and the upper-right corner x, y coordinates.

4. Make the found rectangular 22 to determine if the conditions are met, to find the largest area and.

5. Note that 2 rectangular nesting conditions are also eligible, and only the area of a large rectangular.

The code is as follows:

1#include <cstdio>2#include <cstring>3#include <algorithm>4 5 using namespacestd;6 7 structPillar8 {9     intx;Ten     inty; One}pillar[ *]; A  - structRect - { the     intX1; -     intY1; -     intx2; -     intY2; +}rect[ +]; -  + intmp[ About][ About]; A  at intMain () - { -     intN; -      while(SCANF ("%d", &n) &&N) -     { -         intL =0; inMemset (MP,0,sizeof(MP)); -         intI, J, K; to          for(i =0; I < n; i++) +         { -scanf"%d%d", &pillar[i].x, &pillar[i].y); theMP[PILLAR[I].X][PILLAR[I].Y] =1; *         } $          for(i =0; I < n; i++)Panax Notoginseng         { -              for(j = pillar[i].x +1; J <= $; J + +) the             { +                 if(Mp[j][pillar[i].y]) A                 { the                      for(k = pillar[i].y +1; K <= $; k++) +                     { -                         if(Mp[pillar[i].x][k] &&Mp[j][k]) $                         { $Rect[l].x1 =pillar[i].x; -Rect[l].y1 =pillar[i].y; -RECT[L].X2 =J; theRect[l].y2 =K; -l++;Wuyi                         } the                     } -                 } Wu             } -         } About         intsum =0; $          for(i =0; I < L; i++) -         { -              for(j = i +1; J < L; J + +) -             { A                 ints =0; +                 if((rect[i].x1-rect[j].x1) * (RECT[I].X2-RECT[J].X2) <0&& (rect[i].y1-rect[j].y1) * (Rect[i].y2-rect[j].y2) <0) the                 { -s = Max ((rect[i].y2-rect[i].y1) * (rect[i].x2-rect[i].x1), (rect[j].y2-rect[j].y1) * (RECT[J].X2-rect[j].x1)); $                 } the                 Else if(Rect[i].x1 > Rect[j].x2 | | rect[i].x2 < RECT[J].X1 | | rect[i].y1 > RECT[J].Y2 | | rect[i].y2 <rect[j].y1) the                 { thes = (rect[i].y2-rect[i].y1) * (rect[i].x2-rect[i].x1) + (rect[j].y2-rect[j].y1) * (RECT[J].X2-rect[j].x1); the                 } -sum =Max (sum, s); in             } the         } the         if(sum) About         { theprintf"%d\n", sum); the         } the         Else +         { -printf"imp\n"); the         }Bayi     } the  the  -     return 0; -}

AC is as follows:

The E-pang Palace

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.