Tallest Cow
题目描述
FJ has made a list of R (0 ≤ R ≤ 10,000) lines of the form "cow 17 sees cow 34". This means that cow 34 is at least as tall as cow 17, and that every cow between 17 and 34 has a height that is strictly smaller than that of cow 17.
For each cow from 1..N, determine its maximum possible height, such that all of the information given is still correct. It is guaranteed that it is possible to satisfy all the constraints.
输入
Lines 2..R+1: Two distinct space-separated integers A and B (1 ≤ A, B ≤ N), indicating that cow A can see cow B.
输出
样例输入
9 3 5 5
1 3
5 3
4 3
3 7
9 8
样例输出
5
4
5
3
4
4
5
5
5
分析:第二个数据有什么用!?其实就是差分序列嘛,要注意去重。
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#define range(i,a,b) for(int i=a;i<=b;++i)
#define LL long long
#define rerange(i,a,b) for(int i=a;i>=b;--i)
#define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
using namespace std;
int N,I,H,R,a[],ans;
map<pair<int,int>,bool>vis;
void swap(int &x,int &y){
int tmp=x;
x=y;
y=tmp;
}
void init(){
cin>>N>>I>>H>>R;
range(i,,R){
int x,y;
cin>>x>>y;
if(x>y)swap(x,y);
if(vis[make_pair(x,y)])continue;
vis[make_pair(x,y)]=true;
--a[x+];
++a[y];
}
}
void solve(){
range(i,,N){
ans+=a[i];
cout<<H+ans<<endl;
}
}
int main() {
init();
solve();
return ;
}
Tallest Cow的更多相关文章
- BZOJ1635: [Usaco2007 Jan]Tallest Cow 最高的牛
1635: [Usaco2007 Jan]Tallest Cow 最高的牛 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 346 Solved: 184 ...
- BZOJ 1635: [Usaco2007 Jan]Tallest Cow 最高的牛
题目 1635: [Usaco2007 Jan]Tallest Cow 最高的牛 Time Limit: 5 Sec Memory Limit: 64 MB Description FJ's N ( ...
- 1635: [Usaco2007 Jan]Tallest Cow 最高的牛
1635: [Usaco2007 Jan]Tallest Cow 最高的牛 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 383 Solved: 211 ...
- Tallest Cow POJ - 3263 (区间点修改)
FJ's N (1 ≤ N ≤ 10,000) cows conveniently indexed 1..N are standing in a line. Each cow has a positi ...
- 洛谷P2879 [USACO07JAN]区间统计Tallest Cow
To 洛谷.2879 区间统计 题目描述 FJ's N (1 ≤ N ≤ 10,000) cows conveniently indexed 1..N are standing in a line. ...
- bzoj1635 / P2879 [USACO07JAN]区间统计Tallest Cow
P2879 [USACO07JAN]区间统计Tallest Cow 差分 对于每个限制$(l,r)$,我们建立一个差分数组$a[i]$ 使$a[l+1]--,a[r]++$,表示$(l,r)$区间内的 ...
- 【BZOJ】1635: [Usaco2007 Jan]Tallest Cow 最高的牛(差分序列)
http://www.lydsy.com/JudgeOnline/problem.php?id=1635 差分序列是个好东西啊....很多地方都用了啊,,, 线性的进行区间操作orz 有题可知 h[a ...
- bzoj 1635: [Usaco2007 Jan]Tallest Cow 最高的牛——差分
Description FJ's N (1 <= N <= 10,000) cows conveniently indexed 1..N are standing in a line. E ...
- poj 3263 Tallest Cow(线段树)
Language: Default Tallest Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 1964 Ac ...
随机推荐
- 学习BootStrap3.3.4——敲完全局CSS样式
历时7小时- -(算上晚饭)终于敲完BootStrap CSS样式部分.还是第一次这么持久的敲纯前端,连JS都没有. 正好趁这机会熟悉了Sublime,主要是各个快捷键的用法.目前用到最多的: 而且s ...
- windows下的命令
1.cd 现在默认只能在当前盘符中改变目录,如果要改变盘符则需要多加一个/d命令. cd /d d:/git/springTest 2.chdir 显示当前目录名或改变当前目录. CHDIR [/D] ...
- 自定义 popWindow弹框 工具包
前言:因为Android 没有像IOS一样的ActionSheet,虽然在github上看到有一些类似ActionSheet的库,总觉得不好用,不如自己写一个弹框通用类,样式全部自已来多好. Step ...
- Windows 2008 WinRM和WinRS能帮你做什么?
介绍 WinRM及WinRS更新包含在Windows Vista, Windows Server 2003 R2, Windows Server 2008 (及 Server 2008 Cor ...
- IIS6.0,Apache低版本,PHP CGI 解析漏洞
IIS6.0解析漏洞 在IIS6.0下存在这样的文件"名字.asp;名字.jpg" 代表了jpg文件可以以asp脚本类型的文件执行. 根据这个解析漏洞我们可以上传这种名字类型的图片 ...
- Leetcode 650.只有两个键的键盘
只有两个键的键盘 最初在一个记事本上只有一个字符 'A'.你每次可以对这个记事本进行两种操作: Copy All (复制全部) : 你可以复制这个记事本中的所有字符(部分的复制是不允许的). Past ...
- 查找jar包中.class文件关键字(变量名,字符串)
有时查看日志,常常会发现由框架底层打印的错误日志.要修改这个错误的时候,如果不是对框架特别熟悉,就需要按照可能产生这个错误日志的流程一步一步找,一时半会不一定能找到.比如本人最近对smartfoxse ...
- jquery版手风琴效果
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- 低水平选手的自我救赎 (1)CLRS Exercise 16.5-2
题目大意 给定正整数 $n$ 和一个由 $m$ 个正整数构成的可重集合 $A$,满足 $\forall a\in A, a\le n$ 且 $m\le n$ . 定义 $N_t(A) = |\{a\i ...
- loj 300 [CTSC2017]吉夫特 【Lucas定理 + 子集dp】
题目链接 loj300 题解 orz litble 膜完题解后,突然有一个简单的想法: 考虑到\(2\)是质数,考虑Lucas定理: \[{n \choose m} = \prod_{i = 1} { ...