Alignment of the Planets

来源:互联网 发布:alphago 算法 编辑:程序博客网 时间:2024/05/16 19:54

时限:1000ms 内存限制:10000K  总时限:3000ms

描述:

Actually, this problem is about alignment of N (1 <= N <= 770) cows numbered 1..N who are grazing in their field that is about 15,000x15,000 units. Their grazing locations all fall on integer coordinates in a standard x,y scheme (coordinates are in the range 0..15,000).

Bessie looks up and notices that she is exactly lined up with Sara and Julie. She wonders how many groups of three aligned cows exist within the field.

Given the locations of all the cows (no two cows occupy the same location), figure out all sets of three cows are exactly collinear. Keep track of the sets, sorting the cows in each set by their ID number, lowest first. Then sort the sets by the three ID numbers (lowest first), breaking ties by examining the second and third ID numbers.

输入:

Line 1: A single integer, N

Lines 2..N+1: Line i+1 describes cow i's location with two space-separated integers that are her x and y coordinates

输出:

Line 1: A single integer that is the number of sets of three cows that are exactly collinear. A set of four collinear cows would, of course, result in four sets of three collinear cows.

Lines 2..?: Each line contains three space-separated integers that are the cow ID numbers of three collinear cows. The lines are sorted as specified above. This output section is empty if no collinear sets exist.

输入样例:

8
0 0
0 4
1 2
2 4
4 3
4 5
5 1
6 5

输出样例:

1
1 3 4

提示:

Be careful of floating point arithmetic. Floating point comparison for equality almost never works as well as one would hope.

Explanation of the sample:

Eight cows grazing on a grid whose lower left corner looks like this:

. . . . * . *  
* . * . . . .  
. . . . * . .  
. * . . . . .  
. . . . . * . 
* . . . . . .
The digits mark the collinear cow IDs:

. . . . * . *  
* . 4 . . . .  
. . . . * . .  
. 3 . . . . .  
. . . . . * . 
1 . . . . . .

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 qq密码改忘了怎么办啊 qq头像显示不出来怎么办 qq的重要数据被清理怎么办 把qq数据删除了怎么办 手机qq头像显示不同怎么办 手机qq图片显示不出来怎么办 微信群聊右上角双人头像没了怎么办 支付宝好友没了怎么办 手机qq好友头像没了怎么办 微信语音变成听筒模式怎么办 微信语音为听筒模式怎么办 微信设置成听筒模式怎么办 微信验证看不全怎么办 qq看视频无法放大怎么办 苹果6功能键坏了怎么办 qq显示不了头像和图片怎么办 关于学校随便更换老师家长怎么办 qq群昵称改不了怎么办 电脑qq群视频进不去怎么办 微信头像没保存怎么办 qq群信息不响怎么办 微信封面换不了怎么办 微信头像没有了怎么办 科二超过5次怎么办 蘑菇街个人中心打不开怎么办 蘑菇街的个人中心打不开怎么办 qq群500人满了怎么办 微信零钱发不出来怎么办 微信零钱发不出去怎么办 微信零钱发不了红包怎么办 当亲戚孤立你该怎么办 陌陌好友找不到了怎么办 换了手机号陌陌号找不到怎么办 微信解析包出现问题怎么办 老板找借口不发工资怎么办 苹果手机忘记id帐号密码怎么办 苹果6手机帐号密码忘记怎么办 狗狗在窝里撒尿怎么办 爸妈和媳妇不好怎么办 如果老婆不用老公的钱怎么办 老公不给老婆钱花怎么办