csu 1460: Kastenlauf
来源:互联网 发布:淘宝店装修软件 编辑:程序博客网 时间:2024/04/30 05:38
1460: Kastenlauf
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 90 Solved: 28
[Submit][Status][Web Board]
Description
Input
Output
Sample Input
220 01000 01000 10002000 100020 01000 02000 10002000 2000
Sample Output
happysad
题意:每走50米喝一次,身上带最多只够喝20次,只要能走到商店就补足到20次。 现给n+2个点,起点 ,n个商店 和终点。
#include<stdio.h>#include<queue>#include<iostream>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(){ queue<NODE>q; 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<n; i++) if(vist[i]==0&&abs(p.x-node[i].x)+abs(p.y-node[i].y)<=1000) { vist[i]=1; q.push(node[i]); } } return 0;}int main(){ int t; scanf("%d",&t); while(t--) { scanf("%d",&n); n+=2; for(int i=1; i<=n; i++) scanf("%d%d",&node[i].x,&node[i].y); int flog=bfs(); printf("%s\n",flog?"happy":"sad"); }}
0 0
- csu 1460: Kastenlauf
- CSU 1460: Kastenlauf
- CSU1460: Kastenlauf(DFS)
- cdoj 15 Kastenlauf dfs
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- 一个多maven项目聚合的实例
- java数据结构之栈
- Android开发之动画源码Animation详细分析
- Spring的基本框架
- 指针常量与常量指针 C++
- csu 1460: Kastenlauf
- 中文文献BibTeX制作
- day74(clone用法)
- 25个增强iOS应用程序性能的提示和技巧(初级篇)
- C语言中内存分布及程序运行中(BSS段、数据段、代码段、堆栈)
- 中国互联网企业都是在给外国人打工
- 每天,每周,每月,每年程序员该做的事情
- 警告: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Tes
- 第十一章 字符串和字符串函数(字符串标准输入输出库函数)总结 140525