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辆汽车, ...
随机推荐
- javascript中获取class
js中没有获取class的办法,找了一些封装好的方法,这里整理一下 (1)先进行封装 //封装getClass function getClass(tagName,className) //获得标签名 ...
- CodeForces - 385E Bear in the Field —— 矩阵快速幂
题目链接:https://vjudge.net/problem/CodeForces-385E E. Bear in the Field time limit per test 1 second me ...
- 最优配对问题(集合上的动态规划) —— 状压DP
题目来源:紫书P284 题意: 给出n个点的空间坐标(n为偶数, n<=20), 把他们配成n/2对, 问:怎样配对才能使点对的距离和最小? 题解: 设dp[s]为:状态为s(s代表着某个子集) ...
- llala js弹出层 颜色渐变
网址:http://bbs.csdn.net/topics/370254842
- System.exit(0);和finish();,push原理
今天师姐问我安卓后台的问题,想起几年前做进制转换的时候特意研究了一下怎么才能「不驻留内存地退出」.虽然Android不推荐用户手动关闭进程,但是在那个内存捉襟见肘的年代,不得不考虑内存. 首先直接按b ...
- Careless Me
我在百度知道上提了一个问题: 如图我在menu.xml里试图加一个search的按钮,但我从网页上复制了图中第二个item里的代码,运行的时候,这个item却总是出现在overflow(下拉菜单)里面 ...
- 【CQ18高一暑假前挑战赛3.5】标程
[A:快速幂相关] #include<bits/stdc++.h> using namespace std; int qpow(int a,int x){ a%=;; while(x){ ...
- BZOJ_2216_[Poi2011]Lightning Conductor_决策单调性
BZOJ_2216_[Poi2011]Lightning Conductor_决策单调性 Description 已知一个长度为n的序列a1,a2,...,an. 对于每个1<=i<=n, ...
- C++之萃取技术(traits)
为什么需要类型萃取(特化) 前面我们提到了迭代器,它是一个行为类似于smart pointer之类的东西,主要用于对STL容器中的对象进行访问,而且不暴露容器中的内部结构,而迭代器所指对象的型别称为该 ...
- poj1236学校网络——连通块
题目:http://poj.org/problem?id=1236 通过传输文件的特点可以看出要先求强联通分量,缩点: 问题1:即缩点后入度为0的点,从它们开始传文件可以传给所有学校: 问题2:对于所 ...