1460: Kastenlauf
Time Limit: 1 Sec Memory Limit:
128 MB
Submit: 90 Solved: 28
[Submit][Status][Web
Board]
Description

Input

Output

Sample Input
2
2
0 0
1000 0
1000 1000
2000 1000
2
0 0
1000 0
2000 1000
2000 2000
Sample Output
happy
sad
題意:每走50米喝一次,身上帶最多只夠喝20次,只要能走到商店就補足到20次。 現給n+2個點,起點 ,n個商店 和終點。
#include
#include
#include
using namespace std;
typedef struct nnn
{
int x,y;
}NODE;
int n;
NODE node[105];
int abs(int a)
{
return a>0?a:-a;
}
int bfs()
{
queueq;
NODE p;
int vist[105]={0};
q.push(node[1]);
while(!q.empty())
{
p=q.front(); q.pop();
if(abs(p.x-node[n].x)+abs(p.y-node[n].y)<=1000)
return 1;
for(int i=2; i