HDU6301(2018多校第一场)
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多校第一场)的更多相关文章
- Time Zone 【模拟时区转换】(HDU暑假2018多校第一场)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6308 Time Zone Time Limit: 2000/1000 MS (Java/Others) ...
- 【2018多校第一场】hdu6308-Time Zone(日期)
Problem Description Chiaki often participates in international competitive programming contests. The ...
- HDU6300(2018多校第一场)
Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6300 排个序就好了 #include<iostream> #include& ...
- HDU6308(2018多校第一场)
Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6308 将时间化简为分钟计算,同时不要用浮点数计算,精度会出现问题: 如果采用精度,最好加 ...
- HDU6299(2018多校第一场)
Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6299 两个字符串的排序可以分成四种情况: (1)str1左少右多 vs str2 左多右 ...
- HDU6298(2018多校第一场)
Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6298 打表找规律: #include<bits/stdc++.h> usin ...
- 2019牛客多校第一场 I Points Division(动态规划+线段树)
2019牛客多校第一场 I Points Division(动态规划+线段树) 传送门:https://ac.nowcoder.com/acm/contest/881/I 题意: 给你n个点,每个点有 ...
- 牛客多校第一场 B Inergratiion
牛客多校第一场 B Inergratiion 传送门:https://ac.nowcoder.com/acm/contest/881/B 题意: 给你一个 [求值为多少 题解: 根据线代的知识 我们可 ...
- HDU6581 Vacation (HDU2019多校第一场1004)
HDU6581 Vacation (HDU2019多校第一场1004) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6581 题意: 给你n+1辆汽车, ...
随机推荐
- Python对象拷贝——深拷贝与浅拷贝
对象赋值 浅拷贝 深拷贝 1. 对象赋值 对象的赋值实际上是对对象的引用.也就是说当把一个对象赋值给另一个对象时,只是拷贝了引用.如: >>> t1 = tuple('furzoom ...
- Kattis - whatdoesthefoxsay —— 字符串
题目: Kattis - whatdoesthefoxsay Determined to discover the ancient mystery—the sound that the fox ...
- SCAU RP Test —— 因式分解与组合
D RP Test Time Limit:1000MS Memory Limit:65535K 题型: 编程题 语言: 无限制 描述 LRC是SCAU_ACM校队的主席,职业生涯为校队作过很多 ...
- RobotFramework教程使用笔记——requests和requestslibrary库
Robotframework也可以进行接口测试,只要导入相应的库就可以做到. 一.准备工作 1.导入requests,使用pip,或者手动下载 pip install requests 2.导入req ...
- ffmpeg xcode 中的使用
最近比较闲,苦于ios设备上没有直接播放torrent 文件的软件,开始折腾了.找了不少资料有了思路.但是其中用到了ffmpeg 这个东西. ffmpeg 是通用的一个视频解决框架,用C语言编写,通用 ...
- U盘安装Ubuntu 14.04 LTS正式版 出现如下的提示,不能继续,如何操作?
I had a problem (minor annoyance) when booting up Arch linux with a USB drive connected. The problem ...
- MTK OTG 流程
一.注册mt_usb驱动 kernel-3.18/drivers/misc/mediatek/usb20/mt6735/usb20.c static int __init usb20_init(voi ...
- FFmpeg在Linux下搭建 ***
今天介绍下FFmpeg在Linux下安装编译过程,总体过程比较顺利,就是在ffmpeg等的时间稍长点,仅当记录. 关于FFmpeg FFmpeg是一个开源免费跨平台的视频和音频流方案,属于自由软件,采 ...
- docker容器的参数如何指定配额
docker容器的参数如何指定配额 1. 内存 现在让我看下内存限制. 第一件事需要注意的是,默认一个容器可以使用主机上的所有内存. 如果你想为容器中的所有进程限制内存,使用docker run命令的 ...
- C#视频取帧图
由于项目里页面有许多视频资料需要展示给用户查看,因此需要做一个视频列表,原设计是列表显示视频第一帧图,但实际上很多视频第一帧是纯黑底色. 于是想到用js利用canvas截图,最后发现由于浏览器跨域限制 ...