青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

隨筆 - 87  文章 - 279  trackbacks - 0
<2025年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

潛心看書研究!

常用鏈接

留言簿(19)

隨筆分類(81)

文章分類(89)

相冊

ACM OJ

My friends

搜索

  •  

積分與排名

  • 積分 - 220433
  • 排名 - 118

最新評論

閱讀排行榜

評論排行榜

Space Ant
Time Limit:1000MS? Memory Limit:10000K
Total Submit:113 Accepted:84

Description
The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y1999 and called it M11. It has only one eye on the left side of its head and just three feet all on the right side of its body and suffers from three walking limitations:

  1. It can not turn right due to its special body structure.
  2. It leaves a red path while walking.
  3. It hates to pass over a previously red colored path, and never does that.

The pictures transmitted by the Discovery space ship depicts that plants in the Y1999 grow in special points on the planet. Analysis of several thousands of the pictures have resulted in discovering a magic coordinate system governing the grow points of the plants. In this coordinate system with x and y axes, no two plants share the same x or y.
An M11 needs to eat exactly one plant in each day to stay alive. When it eats one plant, it remains there for the rest of the day with no move. Next day, it looks for another plant to go there and eat it. If it can not reach any other plant it dies by the end of the day. Notice that it can reach a plant in any distance.
The problem is to find a path for an M11 to let it live longest.
Input is a set of (x, y) coordinates of plants. Suppose A with the coordinates (xA, yA) is the plant with the least y-coordinate. M11 starts from point (0,yA) heading towards plant A. Notice that the solution path should not cross itself and all of the turns should be counter-clockwise. Also note that the solution may visit more than two plants located on a same straight line.

Input
The first line of the input is M, the number of test cases to be solved (1 <= M <= 10). For each test case, the first line is N, the number of plants in that test case (1 <= N <= 50), followed by N lines for each plant data. Each plant data consists of three integers: the first number is the unique plant index (1..N), followed by two positive integers x and y representing the coordinates of the plant. Plants are sorted by the increasing order on their indices in the input file. Suppose that the values of coordinates are at most 100.

Output
Output should have one separate line for the solution of each test case. A solution is the number of plants on the solution path, followed by the indices of visiting plants in the path in the order of their visits.

Sample Input

2
10
1 4 5
2 9 8
3 5 9
4 1 7
5 3 2
6 6 3
7 10 10
8 8 1
9 2 4
10 7 6
14
1 6 11
2 11 9
3 8 7
4 12 8
5 9 20
6 3 2
7 1 6
8 2 13
9 15 1
10 14 17
11 13 19
12 5 18
13 7 3
14 10 16

Sample Output

10 8 7 3 4 9 5 6 2 1 10
14 9 10 11 5 12 8 7 6 13 4 14 1 3 2

Source
Tehran 1999

?

#include? < iostream >
#include?
< cmath >
#include?
< algorithm >
using ? namespace ?std;

const ? int ?MAXN? = ? 1000 ;
const ? int ?INF? = ? 2000000000 ;

struct ?XYDATA
{
????
int ?x,?y,?index;
}
;

int ?inorder(XYDATA?a,?XYDATA?b)
{
????
return ?a.y? < ?b.y? || ?(a.y? == ?b.y? && ?a.x? < ?b.x);
}


int ?cross(XYDATA?a,?XYDATA?b)
{
????
return ?a.x? * ?b.y? - ?a.y? * ?b.x;
}


double ?Cos(XYDATA?a,?XYDATA?b)
{
????
return ?(a.x * b.x + a.y * b.y)? / ?(sqrt(a.x * a.x + a.y * a.y)? * ?sqrt(b.x * b.x + b.y * b.y));
}

void ?Solve()
{
????
int ?n;
????
int ?i,?j;
????
int ? out [MAXN];
????
int ?outSize? = ? 0 ?;
????
bool ?mp[ 101 ][ 101 ];
????
int ?t;
????
double ?tmp;
????XYDATA?a[MAXN];
????XYDATA?v,?u;
????
int ?beg;

????scanf(
" %d " ,? & n);
????
for ?(i = 0 ;?i < n;?i ++ )
????????scanf(
" %d%d%d " ,? & a[i].index,? & a[i].x,? & a[i].y);
????
????sort(a,?a
+ n,?inorder);
????
????
for ?(i = 0 ;?i < 101 ;?i ++ )
????????
for ?(j = 0 ;?j < 101 ;?j ++ )
????????????mp[i][j]?
= ? false ;

????v.x?
= ?a[ 0 ].x;
????v.y?
= ? 0 ;
????mp[a[
0 ].x][a[ 0 ].y]? = ? true ;
????beg?
= ? 0 ;
????
out [outSize ++ ]? = ?a[ 0 ].index;
????
for ?(i = 1 ;?i < n;?i ++ )
????
{
????????
bool ?isFind? = ? false ;
????????tmp?
= ? - 2 ;
????????
for ?(j = 0 ;?j < n;?j ++ )
????????????
if ?(beg? != ?j? && ? ! mp[a[j].x][a[j].y])
????????????
{
????????????????u.x?
= ?a[j].x? - ?a[beg].x;
????????????????u.y?
= ?a[j].y? - ?a[beg].y;
????????????????
int ?cro? = ?cross(v,?u);
????????????????
if ?(cro? >= ? 0 )????
????????????????
{
????????????????????isFind?
= ? true ;
????????????????????
if ?(Cos(v,?u)? > ?tmp)?
????????????????????
{
????????????????????????tmp?
= ?Cos(v,?u);
????????????????????????t?
= ?j;
????????????????????}

????????????????}

????????????}

????????
if ?(isFind)
????????
{
????????????v.x?
= ?a[t].x? - ?a[beg].x;
????????????v.y?
= ?a[t].y? - ?a[beg].y;
????????????mp[a[t].x][a[t].y]?
= ? true ;
????????????beg?
= ?t;
????????????
out [outSize ++ ]? = ?a[t].index;
????????}

????????
else ?
????????
{
????????????
break ;
????????}

????}

????printf(
" %d " ,?outSize);
????
for ?(i = 0 ;?i < outSize;?i ++ )
????????printf(
" ?%d " ,? out [i]);
????printf(
" \n " );
}



int ?main()
{
????
int ?n;

????scanf(
" %d " ,? & n);

????
while ?(n -- ? != ? 0 )
????
{
????????Solve();
????}

????
return ? 0 ;
}
posted on 2006-09-27 13:54 閱讀(557) 評論(0)  編輯 收藏 引用 所屬分類: ACM題目
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲免费网址| 久久久久久久网站| 免费久久精品视频| 久久综合九色综合欧美就去吻| av成人免费在线| 欧美日韩午夜精品| 欧美黄污视频| 欧美亚洲一区| 欧美.www| 久久久xxx| 亚洲承认在线| 国产精品亚洲欧美| 亚洲图片欧洲图片av| 久久野战av| 国产女主播一区二区三区| 国产日韩欧美黄色| 国产综合久久久久影院| 亚洲国产国产亚洲一二三| 亚洲免费av电影| 亚洲一区二区三区四区五区黄| 午夜精品成人在线| 欧美www在线| 欧美激情久久久久| 亚洲欧美日韩在线播放| 欧美成人一品| 国产欧美一区二区白浆黑人| 亚洲第一网站免费视频| 亚洲嫩草精品久久| 欧美激情影音先锋| 亚洲伊人久久综合| 欧美激情第六页| 国产精品日韩一区二区三区| 亚洲国产天堂久久综合网| 亚洲欧美日韩久久精品| 欧美国产亚洲另类动漫| 午夜精品网站| 欧美日韩中文字幕在线视频| 激情亚洲成人| 亚洲欧美一区二区三区极速播放| 欧美激情麻豆| 久久久久久久久伊人| 国产精品外国| 亚洲免费中文| 日韩亚洲国产精品| 狂野欧美激情性xxxx欧美| 国产欧美精品一区aⅴ影院| 夜夜爽99久久国产综合精品女不卡| 久久久久久成人| 亚洲综合色视频| 欧美日本在线视频| 亚洲精品裸体| 亚洲大片av| 久久久久国产一区二区| 小黄鸭视频精品导航| 亚洲观看高清完整版在线观看| 99精品热视频| 欧美日韩在线精品| 亚洲视频在线视频| 亚洲国产精品t66y| 久久一综合视频| 在线观看欧美亚洲| 久久国产成人| 久久丁香综合五月国产三级网站| 国产农村妇女毛片精品久久莱园子 | 国产精品黄页免费高清在线观看| 亚洲人成网站精品片在线观看| 久久精品国产99国产精品澳门| 亚洲精品人人| 欧美电影在线| 亚洲精品在线电影| 免费高清在线视频一区·| 最新中文字幕一区二区三区| 免费亚洲视频| 久久九九免费视频| 亚洲国产免费| 亚洲欧洲精品天堂一级| 欧美日韩国产色站一区二区三区| 一本久道综合久久精品| 99精品国产在热久久下载| 国产精品国产三级欧美二区 | 欧美顶级大胆免费视频| 在线观看视频一区二区| 亚洲日韩成人| 国产精品日韩高清| 久久成人18免费网站| 免费成人你懂的| 亚洲欧美成人一区二区在线电影| 性欧美videos另类喷潮| 在线观看一区| 99精品视频免费全部在线| 国产精品日韩在线| 久久综合狠狠| 蜜臀av国产精品久久久久| 99日韩精品| 欧美一级久久久| 亚洲精品在线观看免费| 亚洲自拍偷拍网址| 欧美一级电影久久| 欧美色视频在线| 久久精品99久久香蕉国产色戒| 久久精品一二三| 亚洲一级高清| 久久午夜激情| 亚洲欧美国产高清va在线播| 久久久www| 午夜日韩福利| 欧美日韩国产成人| 玖玖视频精品| 国产精品视频第一区| 亚洲国产精品久久人人爱蜜臀 | 亚洲视频第一页| 一区视频在线播放| 亚洲一级在线观看| 一区二区国产精品| 中文久久精品| 亚洲精品影视在线观看| 亚洲欧美一区二区精品久久久| 激情自拍一区| 亚洲欧美综合网| 在线中文字幕一区| 久久久青草青青国产亚洲免观| 亚洲视频一起| 欧美激情1区| 久久婷婷综合激情| 欧美日韩一区在线观看| 亚洲国产精品久久91精品| 在线成人h网| 最新亚洲激情| 在线欧美日韩精品| 久久国内精品自在自线400部| 亚洲黄色av| 久久国产精品久久久久久电车| 亚洲一区三区视频在线观看 | 亚洲欧美在线免费| 亚洲欧美日韩一区在线| 欧美黄色aaaa| 亚洲啪啪91| 日韩视频一区二区在线观看| 欧美成人一区二区三区在线观看 | 欧美日韩国产999| 亚洲人体偷拍| 一本色道久久88精品综合| 欧美激情91| 一区二区欧美激情| 午夜精品理论片| 国产欧美日韩综合精品二区| 亚洲欧美日韩国产成人精品影院| 亚洲欧美一区二区三区在线| 国产精品国产a| 性做久久久久久久免费看| 久久亚洲美女| 亚洲国产精品美女| 欧美极品欧美精品欧美视频| 亚洲精品国产精品国自产观看| 亚洲午夜视频| 国产麻豆精品theporn| 小黄鸭精品aⅴ导航网站入口| 久久精品欧美| 亚洲黄色有码视频| 欧美体内谢she精2性欧美| 午夜精品一区二区三区四区| 老司机67194精品线观看| 亚洲国产另类 国产精品国产免费| 欧美大色视频| 亚洲伊人第一页| 老司机精品久久| 在线视频亚洲| 国产精品专区第二| 久久激情网站| 99热在这里有精品免费| 久久成人精品无人区| 1000部国产精品成人观看| 欧美三日本三级三级在线播放| 欧美一站二站| 日韩视频精品在线观看| 久久免费视频网| 中日韩高清电影网| 黄色在线一区| 国产精品久久二区二区| 媚黑女一区二区| 午夜在线精品偷拍| 亚洲伦理一区| 欧美成人按摩| 久久精品一区四区| 一区二区三区视频在线播放| 国产伦精品免费视频 | 免费成人在线观看视频| 亚洲欧美日韩国产一区二区三区 | 亚洲国内在线| 久久青草欧美一区二区三区| 国产精品白丝jk黑袜喷水| 久久国产精品99国产| 一区二区三区四区国产精品| 麻豆精品网站| 久久精品天堂| 欧美一区二区三区久久精品茉莉花| 亚洲国产精品欧美一二99| 国产一区二区激情| 国产精品综合久久久| 欧美三级网页|