1011 Regular polygon 6055之神奇的count与[]

2017 Multi-University Training Contest - Team 2 2017-7-27


Regular polygon

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1000    Accepted Submission(s): 368


Problem Description
On a two-dimensional plane, give you n integer points. Your task is to figure out how many different regular polygon these points can make.
 

Input
The input file consists of several test cases. Each case the first line is a numbers N (N <= 500). The next N lines ,each line contain two number Xi and Yi(-100 <= xi,yi <= 100), means the points’ position.(the data assures no two points share the same position.)
 

Output
For each case, output a number means how many different regular polygon these points can make.
 

Sample Input
  
  
4
0 0
0 1
1 1
1 0
6
1 0
0 0
0 1
2 1
1 1
2 0
 

Sample Output
  
  
1
2
 
\


找出所给点可以组成的所有正多边形

因为只有整数点,所以只有正方形

然鹅胖虎皱了皱眉头发现事情并没有那么简单

同样都是1000的数据量

count用时Process exited after 0.2823 seconds with return value 0

[ ]      用时Process exited after 1.369 seconds with return value 0


SURPRISE MOTHERFUCKER



#include<bits/stdc++.h>

using namespace std;


map<pair<int,int>,bool>have;


int xx[1000000];
int yx[1000000];


int main()
{

	int n = 1000;
//	puts("cnm");
//	while(~scanf("%d",&n))
	{
		have.clear();
		for(int i = 1;i <=n;i++)
		{
			
			xx[i] = i,yx[i] = i;
			have[make_pair(xx[i],yx[i])] = 1;
			
		}
		int ans = 0;
		
		for(int i = 1;i<=n;i++)
		{
			for(int j = i+1;j<=n;j++)
			{
				
				int x1 = xx[i];
				int y1 = yx[i];
				int x2 = xx[j];
				int y2 = yx[j];
				int xd = x2-x1;
				int yd = y2-y1;
				
//				printf("	%d %d %d %d\n",x1,y1,x2,y2);
//				printf("%d   ",have[make_pair(x1-yd,y1+xd)]);
//				printf("%d \n",have[make_pair(x2-yd,y2+xd)]);
//				printf("%d   ",have[make_pair(x1+yd,y1-xd)]);
//				printf("%d \n",have[make_pair(x2+yd,y2-xd)]);
//				
//				
				if(have.count(make_pair(x1-yd,y1+xd)))
				if(have.count(make_pair(x2-yd,y2+xd)))
				ans++;
				
				if(have.count(make_pair(x1+yd,y1-xd)))
				if(have.count(make_pair(x2+yd,y2-xd)))
				ans++;
				
//				if((have[make_pair(x1-yd,y1+xd)] == 1)&&(have[make_pair(x2-yd,y2+xd)] == 1))
//				{
//					ans++;
//				}
//				if((have[make_pair(x1+yd,y1-xd)] == 1 )&&have[make_pair(x2+yd,y2-xd)])
//				{
//					ans++;
//				}
//				
				
			}
		}
		
		printf("%d\n",ans/4);
		
	 } 
	




 return 0;
}

/*
6
0 0
0 1
1 0
1 1
2 0
2 1

6
0 0
0 1
2 0
2 1
1 0
1 1

6

1 0
1 1
2 0
2 1
0 0
0 1


*/








#include<bits/stdc++.h>

using namespace std;


map<pair<int,int>,bool>have;


int xx[1000000];
int yx[1000000];


int main()
{

	int n = 1000;
//	puts("cnm");
//	while(~scanf("%d",&n))
	{
		have.clear();
		for(int i = 1;i <=n;i++)
		{
			
			xx[i] = i,yx[i] = i;
			have[make_pair(xx[i],yx[i])] = 1;
			
		}
		int ans = 0;
		for(int i = 1;i<=n;i++)
		{
			for(int j = i+1;j<=n;j++)
			{
				
				int x1 = xx[i];
				int y1 = yx[i];
				int x2 = xx[j];
				int y2 = yx[j];
				int xd = x2-x1;
				int yd = y2-y1;
				
//				printf("	%d %d %d %d\n",x1,y1,x2,y2);
//				printf("%d   ",have[make_pair(x1-yd,y1+xd)]);
//				printf("%d \n",have[make_pair(x2-yd,y2+xd)]);
//				printf("%d   ",have[make_pair(x1+yd,y1-xd)]);
//				printf("%d \n",have[make_pair(x2+yd,y2-xd)]);
//				
//				
//				if(have.count(make_pair(x1-yd,y1+xd)))
//				if(have.count(make_pair(x2-yd,y2+xd)))
//				ans++;
//				
//				if(have.count(make_pair(x1+yd,y1-xd)))
//				if(have.count(make_pair(x2+yd,y2-xd)))
//				ans++;
				
				if((have[make_pair(x1-yd,y1+xd)] == 1)&&(have[make_pair(x2-yd,y2+xd)] == 1))
				{
					ans++;
				}
				if((have[make_pair(x1+yd,y1-xd)] == 1 )&&have[make_pair(x2+yd,y2-xd)])
				{
					ans++;
				}
//				
				
			}
		}
		
		printf("%d\n",ans/4);
		
	 } 
	




 return 0;
}

/*
6
0 0
0 1
1 0
1 1
2 0
2 1

6
0 0
0 1
2 0
2 1
1 0
1 1

6

1 0
1 1
2 0
2 1
0 0
0 1


*/












  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值