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AAAAAjIzADAAAAABGRmAGAAAAACMbIDADAAAAAPTUKzADAAAAAHwYAjMAAAAAGBmBGQAAAACMjMAMAAAAAEZGYAYAAAAAIyMwAwAAAICREZgBAAAAwMgIzAAAAABgZARmAAAAADAyAjMAAAAAGBmBGQAAAACM7P+ZxHNT2kEZWgAAAABJRU5ErkJggg==" alt="" />
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlwAAAB+CAIAAAB+hVjzAAAgAElEQVR4nO2d649Ux5XA938qtZgZYgbNIANhTZDdaUBml4RMHBEje+PppbNYCcl4xzghG7TuTSewayeQp1GIPY7bjneJWYLjxEEEN3YbrNhZDUqbKOAPgPyhpZZqP9zHVNd51Kl7ewaMz+/DqLtu1XnVqTp9H93zd1ZRFEVRFGuttX93qw1QFEVRlNsFLYqKoiiKkqJFUVEURVFStCgqiqIoSgpTFHt771tnMlZNrNm+a/bM21fKKOu98cI6Y4ypdbGjLzT3miXwPqMis8T1rnF28doyqRt2bdXGLdubx166nh7s1gzC3uYLZ48fqhgzPvmZi/1BJun6wd33GlM5+JPXeI2t2VoiZJk8Ko83BSsw9cuXYC8d/uoqYzbd/9X3RyBsKB9iZvD6s0ee2HL3VMWYytjqbbtmT124XN6aP7z804d2bftKq40eHanjinJbIC2KCZWxe379ztXCym7bopiwdtPDi8ujbti1lB2zrevWEkVx4vAL561dfHjTWmMqc0/9OpFz6eTRCWPWbtrz3lKZxNGiCLmji+Lg6P4ZL47r7tvbK20Nn0haFJU7j3BRbD3XtdZeeffsQ/etM8bMHloorIwvivI+5RnWMvjD84fvWv7tuDbbstb2b175WfMrE8YYs/bE7/0q/GJrX2WpXtrkZDGrglfndt4jOU20H4WimLMyM36r1BUmcgYv3j9WMWbtked/17d20L9x7swv9z5yYLmLoqLceUiLos129vsbh6213edayVK53vvjnnvXG1PZVHvoj730iuCVt8/M7tq2eqxijFk9uf5rzePX+gO7tB9Vj7ef3jS52pjK+s07Xjo3VBioPevyhVMPbt+8yhhjVm3e/sC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KvIkxRzH8t0P3XMNlvgQ4ZAO8sukWxl1ni9snumCa/KbpkZK407+CWf72zqCjKx5zRFEVqLPPaK1ewnTn/44siT7AogsKQ/Dh9fmX1WFK68s7T7H8KZYrisWaz4/yKrmuY95/JYK3Ki6JrQF478//cC//Z6bFms+ecFjs9bdZf+I9PFUVR7kBGc/mUPzmDMuXtaAeqKFKWuCYlp0rM5VO+KHY6HbfSYJcxyV81HD7/63U6Pe8fCmZWDWnETFrS26rXnKqWGuZY5RW5XmfoKPy/oFoUFUX5WDOCM0X41jsULFSWLsCGPoNELZFYxT9owxdFO1wIk6LCfIGRv6eIFsLMgCWpMUXRtBa6vU57vl43xqD/1NtRmhZR5/+CalFUFOVjzQrdU/SGM+18uTXE+SIlirDHe9YGvmXuKXpFpda1veTffqKwRXHpjNO9Cpqoc//dDHNP0bt8mjR2F1r0F0iGTnNr9Vav05537jgOVd/TXzXGfPU06YCiKModRtnLp0zhRFskxQ/t4xoDVQeHQ7JHWoxBvqQ4dGqY/FNp9GirXkPPxnL4B23yCuSWveTmontVc9iApf9l6tTFpbdJlyXfhr0bLnvd2vCPAPjVV4uioigfM4r8P0X0EHOOiFYs5rUdLn5uB/4v1RiL9xWIMt9qH8lXMmK/Pggel60Kh9/C3yhQFEW5HYguil7lQwshek5pQ6UuKByeJnrtsNGDcXaY2+I33hIKlOThM0v5bcLiv1GgKIpyZ6A/CI4DbuPdqidQCuoN/bIrJOKEUlEU5U5FiyJJd8G7kggaboENy0Wvc/q0VkRFUT72aFFUFEVRlBQtioqiKIqSokVRURRFUVK0KCqKoihKihZFRVEURUnRoqgoiqIoKVoUFUVRFCVFi6KiKIqipGhRVBRFUZQULYqKoiiKkqJFUVEURVFStCgqiqIoSooWRUVRFEVJ0aKoKIqiKClaFBVFURQlRYuioiiKoqRoUVQURVGUFC2KiqIoipLy/wuMrg+lnp6nAAAAAElFTkSuQmCC" alt="" /> 线段树还是比较薄弱,搞了好长时间,还可以用优先队列做
O((n+m)logn
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
#define for0n for(i=0;i<n;i++)
#define for1n for(i=1;i<=n;i++)
#define w12 while(scanf("%d%d",&n,&m)!=EOF)
#define cl(a) memset(a,0,sizeof(a))
int n,m,t,Min;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root 1,n,1
#define mid ((l+r)>>1)
const int MAXN=;
const int INF = 0x3f3f3f3f;
int head[MAXN],minn[MAXN<<],in[MAXN];
void pushup(int rt){
minn[rt]=min(minn[rt<<],minn[rt<<|]);
}
void build(int l,int r,int rt){
if(l==r){
minn[rt]=in[l];
return;
}
build(lson);
build(rson);
pushup(rt);
}
int query(int k,int l,int r,int rt) {
if(minn[rt]>k) return -;
if (l==r)
{
return l;
}
if(minn[rt<<|]<=k) return query(k,rson);
if(minn[rt<<]<=k) return query(k,lson);
}
void update(int pos,int val,int l,int r,int rt)
{
if(l==r) minn[rt]=val;
else
{
if(pos<=mid) update(pos,val,lson);
else update(pos,val,rson);
pushup(rt);
}
}
struct Edge
{
int to,next;
}edge[MAXN];
int tot=;
void init()
{
tot=;
memset(head,-,sizeof(head));
cl(in);
}
void addedge(int u,int v)
{
edge[tot].to=v;
edge[tot].next=head[u];
head[u]=tot++;
}
int main()
{
int i,j,k;
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
while(scanf("%d%d%d",&n,&m,&k)!=EOF)
{
init();
while(m--)
{
int u,v;
scanf("%d%d",&u,&v);
addedge(u,v);
in[v]++;
}
build(root);
for1n
{
int id=query(k,root); //得到小于k的最大编号的结点
k-=in[id];
in[id]=INF;
update(id,INF,root);
for(j=head[id];j!=-;j=edge[j].next)
{
int v=edge[j].to;
in[v]--;
update(v,in[v],root);
}
printf("%d",id);
if(i<n)printf(" ");
else printf("\n");
}
}
}
2015-07-23:优先队列
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define MOD 1000000007
const int INF=0x3f3f3f3f;
const double eps=1e-;
typedef long long ll;
#define cl(a) memset(a,0,sizeof(a))
#define ts printf("*****\n");
const int MAXN=;
int n,m,tt;
priority_queue<int> q;
vector<int> vc[MAXN];
int in[MAXN];
int head[MAXN];
struct Edge
{
int to,next;
}edge[MAXN];
int tot=;
void init()
{
tot=;
memset(head,-,sizeof(head));
cl(in);
}
void addedge(int u,int v)
{
edge[tot].to=v;
edge[tot].next=head[u];
head[u]=tot++;
}
bool vis[MAXN];
int main()
{
int i,j,k;
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
while(~scanf("%d%d%d",&n,&m,&k))
{
init();
cl(in);
cl(vis);
bool flag=;
int u,v;
for(i=;i<=n;i++)
{
vc[i].clear();
}
for(i=;i<m;i++)
{
scanf("%d%d",&u,&v);
addedge(u,v);
in[v]++;
vc[u].push_back(v);
}
for(i=;i<=n;i++)
{
if(in[i]<=k)
{
q.push(i);
vis[i]=;
}
}
while(!q.empty())
{
int now=q.top();
q.pop();
if(k<in[now])
{
vis[now]=;
continue;
}
k-=in[now];
for(i=;i<vc[now].size();i++)
{
int x=vc[now][i];
in[x]--;
if(!vis[x]&&in[x]<=k)
{
vis[x]=;
q.push(x);
}
}
if(!flag)
{
printf("%d",now);
flag=;
}
else
printf(" %d",now);
}
printf("\n");
}
}
hdu 5195 线段树的更多相关文章
- hdu 5877 线段树(2016 ACM/ICPC Asia Regional Dalian Online)
Weak Pair Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total ...
- hdu 3974 线段树 将树弄到区间上
Assign the task Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 3436 线段树 一顿操作
Queue-jumpers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
- hdu 3397 线段树双标记
Sequence operation Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- hdu 4578 线段树(标记处理)
Transformation Time Limit: 15000/8000 MS (Java/Others) Memory Limit: 65535/65536 K (Java/Others) ...
- hdu 4533 线段树(问题转化+)
威威猫系列故事——晒被子 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Tot ...
- hdu 2871 线段树(各种操作)
Memory Control Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- hdu 4052 线段树扫描线、奇特处理
Adding New Machine Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- hdu 1542 线段树扫描(面积)
Atlantis Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
随机推荐
- [转载]jdk环境变量配置方法
JDK下载 在安装完jdk后,还需要对jdk的环境变量进行配置才能正常使用,下面教大家如何配置jdk环境变量: 1.右键选择 计算机→属性→高级系统设置→高级→环境变量 2.系统变量→新建 变量名:J ...
- iOS 远程推送注册的小问题
iOS8有了新方法,用新方法后,用7.0版本运行会奔溃.只要加一句判断就ok: #ifdef __IPHONE_8_0 // 在 iOS 8 下注册苹果推送,申请推送权限. UIUserNotific ...
- 200行代码实现RPC框架
之前因为项目需要,基于zookeeper和thrift协议实现了一个简单易用的RPC框架,核心代码不超过200行. zookeeper主要作用是服务发现,thrift协议作为通信传输协议, 基于com ...
- ocky勒索软件恶意样本分析1
locky勒索软件恶意样本分析1 1 locky勒索软件构成概述 前些时期爆发的Locky勒索软件病毒这边也拿到了一个样本,简要做如下分析.样本主要包含三个程序: A xx.js文件:Jscript脚 ...
- perl6 HTTP::UserAgent (2)
http://www.cnblogs.com/perl6/p/6911166.html 之前这里有个小小例子, 这里只要是总结一下. HTTP::UserAgent包含了以下模块: --------- ...
- Android启动过程
1.背景知识 Init进程是Linux环境下非常重要的一个进程,而Zygote进程是J ...
- Number of Islands I & II
Given a boolean 2D matrix, find the number of islands. Notice 0 is represented as the sea, 1 is repr ...
- 图解USB协议之一 枚举过程【转】
转自:http://blog.csdn.net/myarrow/article/details/8270060 0. 枚举流程 • 连接了设备的 HUB 在 HOST 查询其状态改变端点 时返回对应的 ...
- CasperJS API中文博客链接
http://www.cnblogs.com/reach296/tag/Casperjs/
- 在Docker中运行EOS(MAC版)
在Docker中运行EOS(MAC版) 在Docker中也可以简单快速的构建EOS.IO.笔者在Mac平台下参考官方文档躺了一次河.记录如下: 安装依赖 Docker 版本 17.05或者更高 tes ...