Bryce1010模板

http://acm.hdu.edu.cn/showproblem.php?pid=6301

队友AC的,没怎么看

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<queue>
#include<functional>
using namespace std;
const int maxn=1e5+5;
int num[maxn],cnt[maxn];
struct node
{
int l,r;
}ar[maxn];
bool cmp(node a,node b)
{
if(a.l!=b.l)
return a.l<b.l;
return a.r>b.r;
}
int main()
{
int t,n,m;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++)
{
scanf("%d%d",&ar[i].l,&ar[i].r);
}
sort(ar,ar+m,cmp);
priority_queue<int,vector<int>,greater<int> > que;
for(int i=1;i<=n;i++)
{
que.push(i);
}
memset(cnt,0,sizeof(cnt));
memset(num,0,sizeof(num));
cnt[0]=1;
int pre=0;
int k=0;
for(int i=0;i<m;i++)
{
if(ar[i].l==pre)
continue;
if(ar[i].r<=k)
continue;
for(int j=pre;j<ar[i].l;j++)
{
if(cnt[num[j]]==0)
{
que.push(num[j]);
cnt[num[j]]=1;
}
}
if(ar[i].l>k)
{
for(int j=ar[i].l;j<=ar[i].r;j++)
{
num[j]=que.top();
cnt[num[j]]=0;
que.pop();
}
}
else
{
for(int j=k+1;j<=ar[i].r;j++)
{
num[j]=que.top();
cnt[num[j]]=0;
que.pop();
}
}
k=ar[i].r;
pre=ar[i].l;
}
for(int i=1;i<=n;i++)
{
if(num[i]>0)
printf("%d%c",num[i],i!=n?' ':'\n');
else
printf("1%c",i!=n?' ':'\n');
}
}
return 0;
}

HDU6301(2018多校第一场)的更多相关文章

  1. Time Zone 【模拟时区转换】(HDU暑假2018多校第一场)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6308 Time Zone Time Limit: 2000/1000 MS (Java/Others)  ...

  2. 【2018多校第一场】hdu6308-Time Zone(日期)

    Problem Description Chiaki often participates in international competitive programming contests. The ...

  3. HDU6300(2018多校第一场)

    Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6300 排个序就好了 #include<iostream> #include& ...

  4. HDU6308(2018多校第一场)

    Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6308 将时间化简为分钟计算,同时不要用浮点数计算,精度会出现问题: 如果采用精度,最好加 ...

  5. HDU6299(2018多校第一场)

    Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6299 两个字符串的排序可以分成四种情况: (1)str1左少右多 vs str2 左多右 ...

  6. HDU6298(2018多校第一场)

    Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6298 打表找规律: #include<bits/stdc++.h> usin ...

  7. 2019牛客多校第一场 I Points Division(动态规划+线段树)

    2019牛客多校第一场 I Points Division(动态规划+线段树) 传送门:https://ac.nowcoder.com/acm/contest/881/I 题意: 给你n个点,每个点有 ...

  8. 牛客多校第一场 B Inergratiion

    牛客多校第一场 B Inergratiion 传送门:https://ac.nowcoder.com/acm/contest/881/B 题意: 给你一个 [求值为多少 题解: 根据线代的知识 我们可 ...

  9. HDU6581 Vacation (HDU2019多校第一场1004)

    HDU6581 Vacation (HDU2019多校第一场1004) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6581 题意: 给你n+1辆汽车, ...

随机推荐

  1. UVA10518 How Many Calls? —— 矩阵快速幂

    题目链接:https://vjudge.net/problem/UVA-10518 题解: 问:求斐波那契数f[n]的时候调用了多少次f[n] = f[n-1] + f[n-2],没有记忆化,一直递归 ...

  2. mac配置apache

    http://www.cnblogs.com/snandy/archive/2012/11/13/2765381.html 用自带的 sudo apachectl -v sudo apachectl ...

  3. H264视频通过RTMP直播

    http://blog.csdn.net/firehood_/article/details/8783589 前面的文章中提到了通过RTSP(Real Time Streaming Protocol) ...

  4. Android应用资源---动画资源(Animation Resources)

    有两种类型的动画资源: 属性动画 在设定的时间内,通过修改与Animator类相关的对象的属性值来创建一个动画. 视图动画 有两种类型的视图动画框架 补间动画(Tween animation):通过执 ...

  5. hdu 1047 Integer Inquiry(大数)

    题意:整数大数加法 思路:大数模板 #include<iostream> #include<stdio.h> #include<stdlib.h> #include ...

  6. Linux_基于Docker快速搭建个人博客网站

    时间:2017年04月28日星期五 说明:基于docker技术,使用jpress开源框架搭建个人博客网站.特别感谢jpress开源项目.系统版本:CentOS 7.2-64bit. 步骤一:准备Doc ...

  7. 51Nod - 1304 :字符串的相似度 (裸的扩展KMP)

    我们定义2个字符串的相似度等于两个串的相同前缀的长度.例如 "abc" 同 "abd" 的相似度为2,"aaa" 同 "aaab& ...

  8. OpenResty创造者

    OpenResty 是一个开源的 Web 平台,用于开发高性能和高动态的 Web 网关或者 Web 应用.OpenResty 最早是为了支持全网搜索引擎周边的相关搜索的 API 接口,后来我们基于 N ...

  9. git add . 的时候遇到warning: LF will be replaced by CRLF inXXX 解决办法

    $ git add . warning: LF will be replaced by CRLF in shop/Runtime/Cache/86bbc820c9ec1 d314a9c71cf5651 ...

  10. activeMQ:java消息机制初试(一)

    前言:自打学习编程以来,就知道activeMQ这么个东西,但是仅仅限于只知其名,不闻其详.现在加入到新的项目组,项目中使用了这个.现在想重新去学习和了解.最后整合成一个完成的demo,在网上看的Dem ...