USACO March. 2012
Connect the Cows
Times17
水题
Landscaping
Flowerpot
Tractor
广搜 搜到边界就可以终止了 没什么难度
#include <stdio.h>
#include <string.h>
#include <queue>
using namespace std;
const int MAX = 1010;
int a[MAX][MAX];
int dir[4][2] = {0,1,0,-1,1,0,-1,0};
struct node
{
int x;
int y;
int step;
bool friend operator < (node a,node b)
{
return a.step > b.step;
}
}s; void bfs()
{
int i;
s.step = 0;
priority_queue <node> q;
q.push(s);
while(!q.empty())
{
node p = q.top();
q.pop();
if(p.x == 0 || p.y == 0 || p.x == 1001 || p.y == 1001)
{
printf("%d\n",p.step);
return;
}
for(i = 0;i < 4; i++)
{
node t;
t.x = p.x + dir[i][0];
t.y = p.y + dir[i][1];
t.step = p.step;
if(a[t.x][t.y] == -1)
continue;
if(a[t.x][t.y])
t.step++;
a[t.x][t.y] = -1;
q.push(t);
} }
}
int main()
{
int n,x,y;
scanf("%d %d %d",&n,&s.x,&s.y);
while(n--)
{
scanf("%d %d",&x,&y);
a[x][y] = 1;
}
bfs();
return 0;
}
Haybale Restacking
USACO March. 2012的更多相关文章
- USACO Feb. 2012
Moo 找规律 吧 第一个是很久以前自己写的递归 #include<stdio.h> __int64 n; __int64 dfs(__int64 l,__int64 r,__int64 ...
- [文章泛读] The varying faces of a program transformation systems (ACM Inroads, 2012)
Beevi S. Nadera, D. Chitraprasad, and Vinod S. S. Chandra. 2012. The varying faces of a program tran ...
- centos各版本信息
CentOS version Architectures RHEL base Kernel CentOS release date RHEL release date Delay (days) 2.1 ...
- HTML5+CSS3学习笔记(二) 页面布局:HTML5新元素及其特性
HTML5的语义化标签以及属性,可以让开发者非常方便地实现清晰的web页面布局,加上CSS3的效果渲染,快速建立丰富灵活的web页面显得非常简单. 本次学习HTML5的新标签元素有: <head ...
- MPLS
Multiprotocol Label Switching From Wikipedia, the free encyclopedia "MPLS" redirects here. ...
- IMS Global Learning Tools Interoperability™ Implementation Guide
Final Version 1.1 Date Issued: 13 March 2012 Latest version: http://www.imsglobal ...
- Linux网络统计工具/命令
我在Linux(基于CentOS 或者 Debian 的发行版)中该如何查看当前网络端口吞吐量的统计信息?在Linux操作系统中如何查看当前内核snmp计数器以及网络端口的统计信息? 你可以使用以下任 ...
- (转)The Road to TensorFlow
Stephen Smith's Blog All things Sage 300… The Road to TensorFlow – Part 7: Finally Some Code leave a ...
- MDX : Non Empty v/s NonEmpty
MDX : Non Empty v/s NonEmpty User Rating: / 50 PoorBest Written by Jason Thomas Friday, 07 May 20 ...
随机推荐
- Ubuntu 12.04环境下配置Postgresql和phppgadmin
Ubuntu 12.04环境下配置Postgresql 9.1 和phppgadmin 本系列文章由ex_net(张建波)编写,转载请注明出处. http://blog.csdn.net/zjianb ...
- java 多个文件打包zip
/** * 多个文件打包成zip */ public class ZipDemo { private static void create() throws Exception{ String pat ...
- verilog中连续性赋值中的延时
上次遇到一个问题.写一个testbench需要移动两个时钟之间的相位.后来一想,貌似我们都是这么写clock的 always #(`P/2) clk = ~clk 我的两个时钟都是这么写,只是p ...
- 深究带PLL的错误复位设计
PLL复位通常犯的错误 或者是像上一篇文章 FPGA知识大梳理(四)FPGA中的复位系统大汇总 中的图一样,也是错误设计.为何呢?看ALTPLL (Phase-Locked Loop) IP Cor ...
- JS 深拷贝
使用递归进行深拷贝 http://lingyu.wang/2014/03/20/js-interview-1/ Object.prototype.deepClone = function() { va ...
- Android Studio ADB响应失败解决方法
当启动Android Studio时,如果弹出 adb not responding. you can wait more,or kill "adb.exe" process ma ...
- nexus REST API /artifact/maven/[resolve|redirect] returns unexpected for v=LATEST
Novice nexus oss (2.0.0) user here – getting unexpected results when requesting v=LATEST artifact fr ...
- 基于Visual C++2013拆解世界五百强面试题--题1-定义各种类型指针
用变量a给出下面的定义 a)一个整型数 b)一个指向整型数的指针 c)一个指向指针的指针,它指向的指针是指向一个整型数 d)一个有10个整型数的数组 e)一个有10个指针 ...
- nginx-lua实现简单权限控制
1,依赖软件:nginx(openresty) mysql(存储用户表)redis(存储用户登录token,有效期1周) create table account( uid integer not n ...
- leetcode_question_67 Add Binary
Given two binary strings, return their sum (also a binary string). For example, a = "11" b ...