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

来源:互联网 发布:如何把linux改为英语 编辑:程序博客网 时间:2024/06/03 20:52

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;}/*60 00 11 01 12 02 160 00 12 02 11 01 161 01 12 02 10 00 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;}/*60 00 11 01 12 02 160 00 12 02 11 01 161 01 12 02 10 00 1*/