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. LightOJ1370 Bi-shoe and Phi-shoe —— 欧拉函数

    题目链接:https://vjudge.net/problem/LightOJ-1370 1370 - Bi-shoe and Phi-shoe    PDF (English) Statistics ...

  2. MYSQL进阶学习笔记十五:MySQL 的账号权限赋予!(视频序号:进阶_33,34)

    知识点十六:MySQL的账号权限赋予(33) 一.MySQL权限简介 关于mysql的权限简单的理解就是mysql允许你做你全力以内的事情,不可以越界.比如只允许你执行select操作,那么你就不能执 ...

  3. struts2中<s:if>标签的使用

    转载:http://blog.sina.com.cn/s/blog_5f9938640100v2kr.html A:<s:if>判断字符串的问题: 1.判断单个字符:<s:if te ...

  4. AndroidStudio检测不到genymotion虚拟设备

    重启adb 单击  Reset adb

  5. android 收集的一些颜色值

    <?xml version="1.0" encoding="utf-8"?> <resources> <color name=&q ...

  6. mysql : mysql 5.6.13 免安装版配置

    前言:真正用到mysql是在公司的第二个项目下,具体的一些在之前的博客文章(http://www.cnblogs.com/zhengzeze/p/5623440.html)中也提到了,其中涉及到,免安 ...

  7. dubbo 自定义过滤器,打印接口调用信息

    dubbo提供了web filter类似的com.alibaba.dubbo.rpc.Filter,这样,我们可以在dubbo提供的服务提供方和消费方都可以自定义过滤 器,从而可以获得方法调用的时间或 ...

  8. Android开发--数据存储之数据库操作

    简介: SQLite 的介绍: SQLite数据库属于文本型的数据库,它是以文本的形式来保存的.Android提供了对 SQLite 数据库的完全支持,应用程序中的任何类都可以通过名称来访问任何的数据 ...

  9. AI—家庭组机器人平台环境配置,高级人工智能实验总结

    首先说一下我的环境:Ubuntu 12.04 32bit,  gcc 4.6.3 一,安装boost 1.48,建议用这个版本的,不然会出现兼容性问题 步骤: 其实在ubuntu下,可以用一下命令直接 ...

  10. 1.1-1.4 hadoop调度框架和oozie概述

    一.hadoop调度框架 Linux Crontab Azkaban https://azkaban.github.io/ Oozie http://oozie.apache.org/ Zeus(阿里 ...