usaco 月赛 2005 january watchcow
2013-09-18 08:13
//By BLADEVIL
var
n, m :longint;
pre, other :array[..] of longint;
last :array[..] of longint;
flag :array[..] of boolean;
tot :longint;
ans :array[..] of longint;
i :longint;
l :longint; procedure connect(x,y:longint);
begin
inc(l);
pre[l]:=last[x];
last[x]:=l;
other[l]:=y;
end; procedure init;
var
i :longint;
x, y :longint;
begin
read(n,m);
for i:= to m do
begin
read(x,y);
connect(x,y);
connect(y,x);
end;
end; procedure dfs(x:longint);
var
p, q :longint;
begin
q:=last[x];
while q<> do
begin
p:=other[q];
if not flag[q] then
begin
flag[q]:=true;
dfs(p);
end;
q:=pre[q];
end;
inc(tot);
ans[tot]:=x;
end; begin
assign(input,'watch.in'); reset(input);
assign(output,'watch.out'); rewrite(output);
init;
dfs();
for i:=tot downto do writeln(ans[i]);
close(input); close(output);
end.
usaco 月赛 2005 january watchcow的更多相关文章
- usaco 月赛 2005 january sumset
2013-09-18 08:23 打表找规律 w[i]:=w[i-1]; 奇 w[i]:=w[i-1]+w[i div 2]; 偶 //By BLADEVIL var w :..] of l ...
- USACO月赛2005 january volume
2013-09-18 08:12 由题可知,ans=∑i ∑j(x[i]-x[j]) 最后整理完之后应该是不同系数的X[i]相加,所以这道题就成了求不同x[i]的系数 对于X[i],它需要减前面(i ...
- USACO月赛数据
终于找到了usaco月赛的数据…… 根据月赛的名称,我们可以写出数据地址.比如08年一月的月赛即是:http://contest.usaco.org/JAN08 这里要注意区分大小写.
- POJ 2230 Watchcow && USACO Watchcow 2005 January Silver (欧拉回路)
Description Bessie's been appointed the new watch-cow for the farm. Every night, it's her job to wal ...
- USACO 2005 January Gold The Wedding Juicer
题目 题目链接,我只在poj上找到了题目,usaco居然上不去. 大意就是说有一些\(1\times 1\times 1\)的小方块堆在一起,问最多能装多少水. 我们在一次测试中出了这题,由于我写水题 ...
- usaco月赛,2017.1总结
T1:跳舞的奶牛 大致题意:一个体积为k的舞台能够同时容纳k只奶牛一起跳舞,他们每头奶牛的跳舞时间不同,如果有一只奶牛跳完了第k+1头奶牛就会立刻上场跳舞,当所有奶牛跳完舞以后我们认为这次表演结束.现 ...
- [题解]某模拟题(USACO月赛部分题+noip2005部分题)
题目描述 农场上有N(1 <= N <= 50,000)堆草,放在不同的地点上.FJ有一辆拖拉机,也在农场上.拖拉机和草堆都表示为二维平面上的整数坐标,坐标值在1..1000的范围内.拖拉 ...
- Telephone Lines USACO 月赛
以前做过这套题目 这个题又重新写了:http://www.cnblogs.com/jh818012/archive/2013/05/05/3182681.html 还是以前的思路 一直错在一个地方:决 ...
- bzoj 1600 & Usaco 月赛 2008 建造栅栏 题解
[原题] 1600: [Usaco2008 Oct]建造栅栏 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 785 Solved: 443 [Subm ...
随机推荐
- Spring 整合 Shiro
一.引入依赖 <!-- spring start --> <dependency> <groupId>org.springframework</groupId ...
- Ubuntu-C++环境设置
在学习C++,顺便想熟悉一下Linux下开发 所以就开始搭建Linux环境 第一步就是下载虚拟机和Ubuntu 虚拟机 vm 12.1 Ubuntu 16 VM安装省略 Ubuntu安装省略 下面是我 ...
- 《百词斩·象形9000》第一册(上) 符号Symbol 1
001-upon prep. 在......上面 Wish upon a star.#对着星星许愿. 002-think V. 想,思索,认为:以为,预料 What do you think?#你认为 ...
- 剑指offer-树的子结构17
题目描述 输入两棵二叉树A,B,判断B是不是A的子结构.(ps:我们约定空树不是任意一个树的子结构) class Solution: def issubTree(self,pRoot1,pRoot2) ...
- LeetCode - 70. Climbing Stairs(0ms)
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- Hyperledger02
docker 思想 模块化: 集装箱 标准化: 运输标准化, 存储方式标准化,API接口的标准化 安全性: 隔离 docker解决什么问题 devops 我这程序程序没问题啊 系统好卡.哪个程序死循环 ...
- Windows下LATEX排版论文攻略—CTeX、JabRef使用心得
笔者刚刚接触到TEX排版,相关知识完全空白,用了两天时间学习并完成了一篇论文的完整排版. 期间遇到不少小问题,着实辛苦,分享至上,现将其解决办法总结归纳,共同学习. 一.工具介绍 TeX是一个很好排版 ...
- poj1789 Truck History最小生成树
Truck History Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 20768 Accepted: 8045 De ...
- 【转】给大家分享一下目前mlc颗粒的内存卡资料
以下信息是LZ从其它论坛上找到的TF卡也是有讲究的,一分价钱一分货 dboy99 楼主 骚(6) #1楼 2015-8-5 14:49引用Micro SD卡也叫TF卡,作为手机扩展存储空间的唯一方式用 ...
- Graphic的一些基本概念
做了张很丑陋的图,估计还不准确...先凑合看吧~