为什么我的程序这组数据过不了ACM

来源:百度知道 编辑:UC知道 时间:2024/06/15 11:45:09
为什么我的程序这组数据过不了?
题目是:
Description

Farmer John has challenged Bessie to the following game: FJ has a board with dots marked at N (2 ≤ N ≤ 200) distinct lattice points. Dot i has the integer coordinates Xi and Yi (-1,000 ≤ Xi ≤ 1,000; -1,000 ≤ Yi ≤ 1,000).

Bessie can score a point in the game by picking two of the dots and drawing a straight line between them; however, she is not allowed to draw a line if she has already drawn another line that is parallel to that line. Bessie would like to know her chances of winning, so she has asked you to help find the maximum score she can obtain.

Input

* Line 1: A single integer: N
* Lines 2..N+1: Line i+1 describes lattice point i with two space-separated integers: Xi and Yi.

Output

* Line 1: A single integer representing the maximal number of lines Bessie can draw, no two of which are parallel.

Sample Input

4
-1 1
-2 0

正确结果是6?你确定你这组测试数据没写错?这不还是个平行四边形么?还是4啊?

那题目里这句话不白写了?
however, she is not allowed to draw a line if she has already drawn another line that is parallel to that line.
Sample里的数据不就是个平行四边形么?

难道我哪里理解错了?

……呵呵~~加油~~早日解决~~

这个实在抱歉,没大看懂你写的程序……我按我的思路写了一下,希望对你有帮助~~
枚举出所有线段的斜率,特殊的斜率无穷大的另设标记,
最后先对斜率排序,找出不重复的,再加上斜率无穷大的(如果有的话),
这样有个问题就是可能超时,你先试试,超时的话在排序上优化一下,直接在计算里循环查找,过滤掉重复的斜率。

仅供参考哈~~

#include <iostream>
#include <cmath>
int Comp(const void *p1,const void *p2 )
{
return *((int *)p2) > *((int *)p1) ? 1 : -1;
}
int main()
{
int i,j,lineNumber;
float k[19900];
int kInf;

int n;
float x[200],y[200];
int result;

scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%f%f",&x[i],&y[i]);
}
lineNumber=0;
kInf=0;
f