Description

Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case.

Input

You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no tw

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
using namespace std;
int p[]={0,1,2,3,4,5,6,7,8};
int x[9],y[9];
int d(int a,int b)
{
return (x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]);
}
int main()
{
int i,j;
for(i=1;i<=8;i++)scanf("%d%d",&x[i],&y[i]); do
{
if(d(p[1],p[2])==d(p[2],p[3]) && d(p[2],p[3])==d(p[3],p[4]) && d(p[3],p[4])==d(p[4],p[1]) && d(p[1],p[3])==d(p[4],p[2])
&& d(p[5],p[6])==d(p[7],p[8]) && d(p[5],p[8])==d(p[6],p[7]) && d(p[5],p[7])==d(p[6],p[8]))
{
return printf("YES\n%d %d %d %d\n%d %d %d %d\n",p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8]),0;
}
}while(next_permutation(p+1,p+9));
printf("NO\n");
return 0; }

  

o points coincide.

Output

Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct.

If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed.

Sample Input

Input
0 0
10 11
10 0
0 11
1 1
2 2
2 1
1 2
Output
YES
5 6 7 8
1 2 3 4
Input
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
Output
NO
Input
0 0
4 4
4 0
0 4
1 2
2 3
3 2
2 1
Output
YES
1 2 3 4
5 6 7 8
一开始不想敲,认为就是个全排列,没什么,网上搜了一下解题报告,确实是用全排列把所有的情况找出来,但是别人用了一个我认为非常吊的方法,调用stl里的全排列函数,屌爆了。
膜拜一下,STL里还有什么宝贝赶紧去找找。

Rectangle and Square的更多相关文章

  1. Codeforces Beta Round #97 (Div. 1) B. Rectangle and Square 暴力

    B. Rectangle and Square 题目连接: http://codeforces.com/contest/135/problem/B Description Little Petya v ...

  2. CodeForces 135 B. Rectangle and Square(判断正方形和 矩形)

    题目:http://codeforces.com/problemset/problem/135/B 题意:给8个点 判断能否用 4个点构成正方形,另外4个点构成 矩形. 输出 第一行是正方形 ,第二行 ...

  3. Rectangle and Square(判断正方形、矩形)

    http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=42#problem/D 改了N多次之后终于A了,一直在改判断正方形和矩形那,判断 ...

  4. Matlab 进阶学习记录

    最近在看 Faster RCNN的Matlab code,发现很多matlab技巧,在此记录: 1. conf_proposal  =  proposal_config('image_means', ...

  5. POJ 3449 Geometric Shapes --计算几何,线段相交

    题意: 给一些多边形或线段,输出与每一个多边形或线段的有哪一些多边形或线段. 解法: 想法不难,直接暴力将所有的图形处理成线段,然后暴力枚举,相交就加入其vector就行了.主要是代码有点麻烦,一步一 ...

  6. RTTI (Run-Time Type Identification,通过运行时类型识别) 转

    参考一: RTTI(Run-Time Type Identification,通过运行时类型识别)程序能够使用基类的指针或引用来检查这些指针或引用所指的对象的实际派生类型.   RTTI提供了以下两个 ...

  7. An Introduction to Interactive Programming in Python (Part 1) -- Week 2_1 练习

    # Practice Exercises for Functions # Solve each of the practice exercises below. # 1.Write a Python ...

  8. cdoj 93 King's Sanctuary 傻逼几何题

    King's Sanctuary Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/sho ...

  9. C++中str1::function和bind

    在C++的TR1中(TechnologyReport)中包括一个function模板类和bind模板函数,使用它们能够实现类似函数指针的功能,但却却比函数指针更加灵活,特别是函数指向类的非静态成员函数 ...

随机推荐

  1. BIT_COUNT()和BIT_OR()

    在学习MySQL手册时,看到根据天数计算访问量时,出现了BIT_COUNT()和BIT_OR()两个函数来处理天数计算的问题 所使用的表格信息如下: mysql> select year,mon ...

  2. (转载)解决WPF动画属性锁死问题

    此文来自: 马开东博客 转载请注明出处 网址:http://www.makaidong.com 一般锁死问题都是出在后台代码写的动画中,以下为转载的解决方案! 方法一:将动画的 FillBehavio ...

  3. haporxy 负载elasticsearch

    <pre name="code" class="html">-bash-4.1# cat /etc/haproxy/haproxy.cfg glob ...

  4. ASP.NET应用程序和ASP.NET网站所共有的文件: App_Browsers 等

    App_Browsers  包含 ASP.NET 用于标识个别浏览器并确定其功能的浏览器定义 (.browser) 文件.有关更多信息,请参见浏览器定义文件架构(browsers 元素)和如何:在 A ...

  5. juicer模板引擎使用

    http://www.juicer.name/ <script src="~/Scripts/jquery-1.8.2.min.js"></script> ...

  6. Wiggle Sort 解答

    Question Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= num ...

  7. 飘逸的python - 性能调优利器profile及其意义

    VIM 的作者Bram Moolenaar在一篇叫高效文本编辑器的7个习惯的ppt中有这么一段话. Three basic steps 1.    Detect inefficiency 2.    ...

  8. 后台数据导出为Excel

    数据导出的方法如下: 一.下载office的类库:microsoft.office.interop.excel.zip 根据电脑安装的office版本选择引入相应的类库,office2007选择12. ...

  9. UIView 转 UIImage

    这个方法很实用,特别是在做水印相机得时候... - (UIImage*) imageWithUIView:(UIView*) view{ // 创建一个bitmap的context // 并把它设置成 ...

  10. [Protractor] Locators and Suites in Protractor

    HTML: <ul class="list"> <li ng-repeat="item in itmes" ng-click="se ...