编程介的小学生 2017-09-03 14:15 采纳率: 20.5%
浏览 824
已采纳

Two Pipelines

There are two oil pipelines going through Flatland. Each pipeline can be considered as a line on the plane.

Recently the president of Flatland has decided to bring oil to all n cities of Flatland. Therefore he would like to build pipes from each city to one of the pipelines. The minister of industry and education has provided him with data about demand for oil in each city. Transporting a barrel of oil for one kilometer costs 1 flatlar.

The president ordered to connect each city to the closest pipleine, but it turned out that there is one problem. One pipeline belongs to a strong Hrundi Empire, while the other belongs to Bordland Republic. Since president wants to keep good relationships with both countries, he must not give preference to one of the pipelines. That is, if there would be x cities connected to one pipeline and y cities connected to the other, |x - y| must not exceed c .

Help president to decide which city should be connected to which pipeline, so that he keeps his international reputation clean, and spends as few money as possible.

Input

There are mutiple cases in the input file.

The first line of the input file contains n and c (1 <= c <= n <= 200 ). The second line contains the description of the first pipeline --- coordinates of two different points that are lying on it: x1 , y1 , x2 , y2 . The third line describes the second pipeline in the same format.

The following n lines describe cities. Each city is described with three integer numbers: its coordinates and the demand for the oil in thousands of barrels per day (it does not exceed 1000 ).

All coordinates are integer, given in kilometers and do not exceed 104 by absolute values. No two cities coincide. Pipelines do not coincide either.

There is an empty line after each case.

Output

For each city output 1 if it must be connected to the first pipeline, or 2 if it must be connected to the second pipeline.

There should be am empty line after each case.
Sample Input

3 1
0 0 10 0
0 5 7 5
-2 1 1
1 1 1
4 2 10

Sample Output

1 2 1

  • 写回答

1条回答

  • threenewbee 2017-09-17 20:25
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用