| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么会TLE?已经是O(n^2logn)的了啊!#include<iostream>
#include<algorithm>
#include<cmath>
const double Pi=100000000;
using namespace std;
struct
{
double x,y;
}d[701];
int main()
{
int n,i,j,Max;
double p[701];
while(cin >> n,n!=0){
for(i=0;i<n;i++) cin >> d[i].x >> d[i].y;
Max=1;
for(i=0;i<n;i++)
{
int k=0;
for(j=0;j<n;j++)
{
if(j==i) continue;
if(d[j].x!=d[i].x) p[k++]=(d[j].y-d[i].y)/(d[j].x-d[i].x);
else p[k++]=Pi;
}
sort(p,p+k);
int t=1;
for(j=1;j<k;j++){
if(p[j]==p[j-1]) t++;
else{
if(Max<t) Max=t;
t=1;
}
}
}
cout << Max+1 << endl;
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator